Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Form lib] Fix regression on field not being validated after reset to its default value. #76379

Merged
merged 2 commits into from
Sep 3, 2020

Conversation

sebelga
Copy link
Contributor

@sebelga sebelga commented Sep 1, 2020

I introduced a regression when I added an if condition to prevent validating when the field value equals the initial value or default value. This if was added to prevent validating after we reset the field value. This created a regression as now the validation was never run on empty fields.

This regression was raised by @rylnd here: #76138 (comment)

In this PR I fixed the regression and added the tests to make sure both behaviour work correctly:

  • When we reset the form (and the field), the fields are not validated and the form validity stays "undefined"
  • When the field value changes back to its default value, the field validation runs and display and update the form isValid state.

…lue === defaultValue

I introduced a regression when I added an "if" condition to prevent validation when the field value === the initial value. This if was added to prevent validating after resetting the field value. This created a regression as now the validation was never run on empty fields.
@sebelga sebelga requested a review from a team as a code owner September 1, 2020 14:05
@sebelga sebelga added bug Fixes for quality problems that affect the customer experience release_note:skip Skip the PR/issue when compiling release notes Team:Kibana Management Dev Tools, Index Management, Upgrade Assistant, ILM, Ingest Node Pipelines, and more v7.10.0 v8.0.0 labels Sep 1, 2020
@elasticmachine
Copy link
Contributor

Pinging @elastic/es-ui (Team:Elasticsearch UI)

Copy link
Contributor

@rylnd rylnd left a comment

Choose a reason for hiding this comment

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

@sebelga I confirmed these changes against my branch. Thank you for the quick fix!

@kibanamachine
Copy link
Contributor

💚 Build Succeeded

Build metrics

page load bundle size

id value diff baseline
esUiShared 993.7KB +56.0B 993.6KB

To update your PR or re-run it, just comment with:
@elasticmachine merge upstream

Copy link
Contributor

@yuliacech yuliacech left a comment

Choose a reason for hiding this comment

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

Hi @sebelga , great work on fixing this issue in the form lib!
I haven't tested locally, the code looks good to me. Good job on adding more tests for the lib.

</Form>
);
};
return TestComp;
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: TestComp variable is not necessarily needed here.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

True, but sometimes adding the var makes it a little bit clearer when scanning the file than directly returning a function. I guess it depends on my level of fatigue 😊
In this case, I clearly read what is the component without any extra parsing.

@sebelga
Copy link
Contributor Author

sebelga commented Sep 3, 2020

Thanks for the review @rylnd and @yuliacech !

@sebelga sebelga merged commit 182e0de into elastic:master Sep 3, 2020
@sebelga sebelga deleted the bug/form-lib-fix-regression branch September 3, 2020 06:58
sebelga added a commit that referenced this pull request Sep 3, 2020
jloleysens added a commit to jloleysens/kibana that referenced this pull request Sep 3, 2020
…nes/processors-forms-k-s

* 'master' of github.com:elastic/kibana: (216 commits)
  [Ingest Manager] Split Registry errors into Connection & Response (elastic#76558)
  [Security Solution] add an excess validation instead of the exact match (elastic#76472)
  Introduce TS incremental builds & move src/test_utils to TS project  (elastic#76082)
  fix bad merge (elastic#76629)
  [Newsfeed] Ensure the version format when calling the API (elastic#76381)
  remove server_extensions mixin (elastic#76606)
  Remove legacy applications and legacy mode (elastic#75987)
  [Discover] Fix sidebar element focus behavior when adding / removing columns (elastic#75749)
  Replace FetchOptions with ISearchOptions (elastic#76538)
  Move streams utils to the core  (elastic#76397)
  [Ingest Manager] Wording & linking improvements (elastic#76284)
  remove legacy kibana plugin (elastic#76064)
  [Form lib] Fix regression on field not being validated after reset to its default value. (elastic#76379)
  Legacy SO import: Fix bug causing multiple overrides to only show the last confirm modal (elastic#76482)
  [APM] Service maps layout enhancements (elastic#76481)
  [Security Solution][Detection Engine] Remove RuleTypeSchema in favor of Type for TypeScript (elastic#76586)
  [Security Solution][Exceptions] - Updates enum schema and tests (elastic#76544)
  Index Pattern class - remove toJSON and toString (elastic#76246)
  skip failing suite (elastic#76581)
  Split up and clarify Enterprise Search codeowners (elastic#76580)
  ...

# Conflicts:
#	x-pack/plugins/ingest_pipelines/public/application/components/pipeline_processors_editor/components/manage_processor_form/processor_settings_fields.tsx
#	x-pack/plugins/ingest_pipelines/public/application/components/pipeline_processors_editor/components/manage_processor_form/processors/foreach.tsx
jloleysens added a commit to jloleysens/kibana that referenced this pull request Sep 3, 2020
…oleysens/kibana into ingest-pipelines/processors-forms-k-s

* 'ingest-pipelines/processors-forms-k-s' of github.com:jloleysens/kibana: (216 commits)
  [Ingest Manager] Split Registry errors into Connection & Response (elastic#76558)
  [Security Solution] add an excess validation instead of the exact match (elastic#76472)
  Introduce TS incremental builds & move src/test_utils to TS project  (elastic#76082)
  fix bad merge (elastic#76629)
  [Newsfeed] Ensure the version format when calling the API (elastic#76381)
  remove server_extensions mixin (elastic#76606)
  Remove legacy applications and legacy mode (elastic#75987)
  [Discover] Fix sidebar element focus behavior when adding / removing columns (elastic#75749)
  Replace FetchOptions with ISearchOptions (elastic#76538)
  Move streams utils to the core  (elastic#76397)
  [Ingest Manager] Wording & linking improvements (elastic#76284)
  remove legacy kibana plugin (elastic#76064)
  [Form lib] Fix regression on field not being validated after reset to its default value. (elastic#76379)
  Legacy SO import: Fix bug causing multiple overrides to only show the last confirm modal (elastic#76482)
  [APM] Service maps layout enhancements (elastic#76481)
  [Security Solution][Detection Engine] Remove RuleTypeSchema in favor of Type for TypeScript (elastic#76586)
  [Security Solution][Exceptions] - Updates enum schema and tests (elastic#76544)
  Index Pattern class - remove toJSON and toString (elastic#76246)
  skip failing suite (elastic#76581)
  Split up and clarify Enterprise Search codeowners (elastic#76580)
  ...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Fixes for quality problems that affect the customer experience release_note:skip Skip the PR/issue when compiling release notes Team:Kibana Management Dev Tools, Index Management, Upgrade Assistant, ILM, Ingest Node Pipelines, and more v7.10.0 v8.0.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants