-
Notifications
You must be signed in to change notification settings - Fork 8.3k
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] Add useFormData() hook to listen to fields value changes #76107
Conversation
Pinging @elastic/es-ui (Team:Elasticsearch UI) |
For some reason this handler was not exposed directly on the form. The way to call the validate() method was by first subscribing to form changes and save a ref of the handler. A very indirect process when we do have the handler ready to be public.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great work @sebelga! I really like the addition of the new hook. I tested the meta toggle in the index templates form and it still worked as expected.
What is the timeline for removing the use of FormDataProvider
and form.subscribe()
across our forms? Is it worth adding a deprecation warning in form_data_provider
?
I found a couple bugs while testing, although I don't think they are related to your changes. I can open up separate issues if you'd like.
@@ -0,0 +1,234 @@ | |||
/* |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great work with the tests 🎉
Thanks for the review @alisonelizabeth ! Great catch for the 2 issues, there are not related to my changes bug I fixed them in this PR. For the ComboBox issue, I added an optional
I don't have a timeline but I'd love to be able to do it in one go after I finish writing the docs. For now the important is not to add any new ones to future forms 😊 |
💚 Build SucceededBuild metrics@kbn/optimizer bundle module count
async chunks size
page load bundle size
oss distributable file count
distributable file count
History
To update your PR or re-run it, just comment with: |
…hanges (elastic#76107)" This reverts commit ef7246f.
This PR adds a new hook on the form lib to listen to field value changes. With this hook we will be able to deprecate the
<FormDataProvider />
.This hook also deprecates the use of
form.subscribe()
, so the form lib is more aligned with the React API with the use ofuseEffect()
.Note: None of the above will be removed just yet, we will remove them in separate PR.