Skip to content

Conversation

@Bargs
Copy link
Contributor

@Bargs Bargs commented Aug 21, 2019

Summary

This PR changes the save query form to only validate its inputs on blur. Previously we validated on every change. This could lead to the errors flashing in the user's face before they're done typing a valid input. For example, we allow spaces in the name field, but not at the beginning or end of the name. So if a user typed this is a long name with spaces they would see the error pop up every time they type a space, only to have it disappear when they type the next letter.

My only concern with the new implementation is that after fixing the error, the user must know to click or tab out of the input to re-run the validation and re-enable the save button. @elastic/kibana-design do we have any best practices for solving this in a better way?

Checklist

Use strikethroughs to remove checklist items you don't feel are applicable to this PR.

- [ ] This was checked for cross-browser compatibility, including a check against IE11
- [ ] Any text added follows EUI's writing guidelines, uses sentence case text and includes i18n support
- [ ] Documentation was added for features that require explanation or tutorials

For maintainers

- [ ] This was checked for breaking API changes and was labeled appropriately
- [ ] This includes a feature addition or change that requires a release note and was labeled appropriately

@Bargs Bargs added release_note:fix Team:Visualizations Team label for Lens, elastic-charts, Graph, legacy editors (TSVB, Visualize, Timelion) t// v8.0.0 v7.4.0 labels Aug 21, 2019
@Bargs Bargs requested review from a team and TinaHeiligers August 21, 2019 22:43
@elasticmachine
Copy link
Contributor

Pinging @elastic/kibana-app

@elasticmachine
Copy link
Contributor

💔 Build Failed

@Bargs
Copy link
Contributor Author

Bargs commented Aug 22, 2019

Realized I was missing an easy solution yesterday. I simply re-validate on every render if the form currently has errors. So errors will only appear on blur, but they will disappear as soon as the user has fixed them.

betterValidation

Copy link
Contributor

@TinaHeiligers TinaHeiligers left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I pulled in the code and tested it in Chrome, Firefox and Safari. The change works well and reduces the visual noise while filling in the saved query form.
The failed functional test is a result of form validation happening only after the name field is blurred and can be fixed as follows in test/functional/services/saved_query_management_component.js:

async saveNewQueryWithNameError(name) {
      await this.openSavedQueryManagementComponent();
      await testSubjects.click('saved-query-management-save-button');
      if (name) {
        await testSubjects.setValue('saveQueryFormTitle', name);
      }
      await testSubjects.setValue('saveQueryFormDescription', 'description'); // <--- add this
      const saveQueryFormSaveButtonStatus = await testSubjects.isEnabled('savedQueryFormSaveButton');
      expect(saveQueryFormSaveButtonStatus).to.not.eql(true);
      await testSubjects.click('savedQueryFormCancelButton');
    }

// Form input validation only happens onBlur. Clicking the save button should de-focus the
// input element and the validation should prevent a save from actually happening if there's
// an error.
await testSubjects.click('savedQueryFormSaveButton');
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should also work.

@elasticmachine
Copy link
Contributor

💚 Build Succeeded

@Bargs Bargs removed the request for review from a team August 22, 2019 21:38
@Bargs Bargs merged commit bba04a5 into elastic:master Aug 22, 2019
Bargs added a commit to Bargs/kibana that referenced this pull request Aug 22, 2019
This PR changes the save query form to only validate its inputs on blur. Previously we validated on every change. This could lead to the errors flashing in the user's face before they're done typing a valid input. For example, we allow spaces in the name field, but not at the beginning or end of the name. So if a user typed this is a long name with spaces they would see the error pop up every time they type a space, only to have it disappear when they type the next letter.
Bargs added a commit that referenced this pull request Aug 23, 2019
This PR changes the save query form to only validate its inputs on blur. Previously we validated on every change. This could lead to the errors flashing in the user's face before they're done typing a valid input. For example, we allow spaces in the name field, but not at the beginning or end of the name. So if a user typed this is a long name with spaces they would see the error pop up every time they type a space, only to have it disappear when they type the next letter.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

release_note:fix Team:Visualizations Team label for Lens, elastic-charts, Graph, legacy editors (TSVB, Visualize, Timelion) t// v7.4.0 v8.0.0

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants