-
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] Export internal state instead of raw state #80842
Conversation
b033959
to
f5edadc
Compare
48ed86c
to
364855c
Compare
Pinging @elastic/es-ui (Team:Elasticsearch UI) |
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.
That looks Amazing, Thank you @sebelga for all the hard work! 💪
SIEM/Endpoint LGTM! 🚀
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 tested proposed changes locally in ingest pipelines plugin and in index lifecycle management.
Left a couple of comments.
? serializer(unflattenObject<I>(fieldsValue)) | ||
: unflattenObject<T>(fieldsValue); |
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.
So the form lib, internally still stores paths as my.path[0].to.something
? We just don't expose this to consumer code?
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.
Yes. I thought in changing that but when I started to write the logic to remove a field from an array (e.g. second position) from inside an object (at any depth) I thought... let's keep it flat until the last minute! 😄 It makes the internal logic much simpler.
if (resetValues) { | ||
getFormData$().next(currentFormData as T); | ||
updateFormData$(currentFormData); |
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.
Very nice update! RIP as
!
/** | ||
* We do want to offer to the consumer a handler to serialize the form data that changes each time | ||
* the formData **state** changes. This is why we added the "formData" dep to the array and added the eslint override. | ||
*/ | ||
const serializer = useCallback(() => { | ||
return getFormData(); | ||
// eslint-disable-next-line react-hooks/exhaustive-deps | ||
}, [getFormData, formData]); |
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.
👍 Happy for the form lib to guarantee this for consumers
💚 Build SucceededMetrics [docs]async chunks size
page load bundle size
History
To update your PR or re-run it, just comment with: |
Thanks for the review @jloleysens ! |
* master: (64 commits) Rename Security Solution Bug Template (elastic#81187) Update links (elastic#81125) Specify format for date range query (elastic#81025) [Alerting] Improve toast when alert is created (elastic#80327) [UX] Add empty states (elastic#80904) Add TS config for kibana_legacy (elastic#80992) [Telemetry] Add method to enable endpoint security data usage example (elastic#80940) [Alerting] Add scoped cluster client to alerts and actions services (elastic#80794) Fix reactRouterNavigate when used with a string (elastic#80520) [Security Solution] [Detections] Read privileges for dependencies (elastic#80852) [ML] Fixing exclude frequent in advanced wizard (elastic#81121) Fix security solution template label (elastic#80976) [DOCS] Update index management docs (elastic#80893) [APM] Error rate on service list page is not in sync with the value at the transaction page (elastic#80814) skip flaky suite (elastic#81072) [Task Manager] Cleans up legacy plugin structure (elastic#80381) Support unsigned_long fields (elastic#81115) [Form lib] Export internal state instead of raw state (elastic#80842) [Lens] Add toast notification when visualization is saved (elastic#80788) Index pattern edit field formatter API (elastic#78352) ...
Read the issue for context: #78589
This PR replaces the raw (flat object of value) state exposed to the consumer and replaces it with the form internal state (which default to the form "out" interface if no deserializer was provided).
Fixes #78589
cc @rylnd @patrykkopycinski