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] Memoize form hook object and fix hook array deps #71237

Merged
merged 17 commits into from
Jul 15, 2020

Conversation

sebelga
Copy link
Contributor

@sebelga sebelga commented Jul 9, 2020

This PR correctly memoize the handlers and variables of the form lib hooks. It also declares the correct hooks deps to get us one step closer to close #49554

I have also updated the forms of index management to correctly declare their useEffect deps.

How to test

There isn't an easy way to test. We need to go through different forms and make sure everything works as expected. I have already spent a large amount of time testing the index templates forms, mainly the mappings editor forms.

@sebelga sebelga requested a review from a team as a code owner July 9, 2020 13:06
@sebelga sebelga added release_note:skip Skip the PR/issue when compiling release notes v7.9.0 v8.0.0 Team:Kibana Management Dev Tools, Index Management, Upgrade Assistant, ILM, Ingest Node Pipelines, and more labels Jul 9, 2020
@elasticmachine
Copy link
Contributor

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

Copy link
Contributor

@jloleysens jloleysens left a comment

Choose a reason for hiding this comment

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

@sebelga awesome work!

Definitely tricky to spot runtime staleness errors if there are any 😅 but the proposed changes all look good to me and I'm glad we could tackle this issue!

I clicked through different forms in the mappings editor and in ingest processors editor and they seemed to work as expected.

@sebelga
Copy link
Contributor Author

sebelga commented Jul 9, 2020

Thanks for the review @jloleysens ! Yes it is tricky to detect. I had quite a few console.log() to detect infinite re-renders, and got a few of them solved. I admit that there is a problem with the data flow inside the lib that I'd like to address in 7.10 to make changes more predictable.
But this PR is already a good step forward to make things cleaner for the consumer.

Copy link
Contributor

@alisonelizabeth alisonelizabeth left a comment

Choose a reason for hiding this comment

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

LGTM! My review was testing only. Tested ingest node pipelines, index templates and component template forms and did not spot any regressions.

@sebelga
Copy link
Contributor Author

sebelga commented Jul 9, 2020

@elasticmachine merge upstream

@sebelga
Copy link
Contributor Author

sebelga commented Jul 9, 2020

@elasticmachine merge upstream

@alisonelizabeth
Copy link
Contributor

@elasticmachine merge upstream

@alisonelizabeth
Copy link
Contributor

@elasticmachine merge upstream

@alisonelizabeth
Copy link
Contributor

@elasticmachine merge upstream

@alisonelizabeth
Copy link
Contributor

@sebelga I believe the test failures are valid, as the security_solution plugin uses the form lib and the tests are not failing on other tracked branches.

@sebelga sebelga requested review from a team as code owners July 13, 2020 10:58
@sebelga
Copy link
Contributor Author

sebelga commented Jul 13, 2020

@elasticmachine merge upstream

Copy link
Contributor

@yctercero yctercero left a comment

Choose a reason for hiding this comment

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

Thanks so much for the updates! This is much cleaner. I did notice a few react warnings pop up in the step_about_rule that I don't think were there before (just quickly checked against a master). Not sure if they're related to the changes?

@sebelga
Copy link
Contributor Author

sebelga commented Jul 13, 2020

Thanks for the review @yctercero ! I will check those React warnings 👍

isNew: false,
};
setMyStepData(myDefaultValues);
setFieldValue(form, schema, myDefaultValues);
Copy link
Contributor

Choose a reason for hiding this comment

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

@sebelga we have this pattern in several of these "rule creation step" forms. Do you intend to change the others after we verify this one?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@rylnd We will have to. setFieldValue was probably a hack that you had to create because of an unexpected behaviour on the form lib. Now that all the handlers are memoized and the form object too, this hack is not necessary anymore. I will review it tomorrow with Patryk.

Copy link
Contributor

Choose a reason for hiding this comment

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

@sebelga yes, absolutely! Very excited to clean things up once this is merged 🙏

Copy link
Member

Choose a reason for hiding this comment

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

++ @rylnd's sentiment! 🙂 Between this and #60602 we'll really be able to clean things up on our end. Thanks for all the work here @sebelga!

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks @spong ! And good that you bring #60602 back to my attention 👍

@sebelga sebelga added 7.10.0 and removed v7.9.0 labels Jul 14, 2020
sebelga and others added 4 commits July 15, 2020 09:14
…memoize

# Conflicts:
#	x-pack/plugins/security_solution/public/cases/components/add_comment/index.tsx
#	x-pack/plugins/security_solution/public/cases/components/create/index.tsx
#	x-pack/plugins/security_solution/public/cases/components/user_action_tree/user_action_markdown.tsx
@kibanamachine
Copy link
Contributor

💚 Build Succeeded

Build metrics

async chunks size

id value diff baseline
indexManagement 2.0MB +829.0B 2.0MB
securitySolution 9.3MB -6.8KB 9.3MB
total - -6.0KB -

miscellaneous assets size

id value diff baseline
esUiShared 395.9KB +793.0B 395.1KB
upgradeAssistant 22.5KB -15.0B 22.6KB
total - +778.0B -

page load bundle size

id value diff baseline
esUiShared 1008.8KB +2.5KB 1006.2KB

History

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

Copy link
Contributor

@stephmilovic stephmilovic left a comment

Choose a reason for hiding this comment

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

Case files and manual testing of the case forms all LGTM, thanks!

@sebelga
Copy link
Contributor Author

sebelga commented Jul 15, 2020

Thanks for the review @stephmilovic !

@sebelga sebelga merged commit 99255d8 into elastic:master Jul 15, 2020
@sebelga sebelga deleted the fix/form-lib-memoize branch July 15, 2020 14:58
gmmorris added a commit to gmmorris/kibana that referenced this pull request Jul 15, 2020
* master:
  [Form lib] Memoize form hook object and fix hook array deps (elastic#71237)
  [uiActions] Support emitting nested triggers and actions (elastic#70602)
  add short sleep before clicking Remove on sample data (elastic#71104)
  Fixed the beta badge layout. (elastic#71835)
  Restores task for downloading Chromium builds (elastic#71749)
  [logging] Format new platform json logging to ECS (elastic#71138)
  add policy details and update SO limit requests (elastic#71789)
  Convert vis_type_vega to Typescript (elastic#68915)
  [ML] Fix UI Actions context menu positioning for the Anomaly Swim Lane (elastic#71839)
sebelga added a commit that referenced this pull request Jul 16, 2020
…1237) (#71875)

Co-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com>
Co-authored-by: Patryk Kopycinski <contact@patrykkopycinski.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
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.

Remove temporary src/plugins/es_ui_shared eslint overrides