-
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
[App Search] Relevance Tuning: Fix unsaved changes bug #104951
[App Search] Relevance Tuning: Fix unsaved changes bug #104951
Conversation
- The fix for this is to change MultiInputRows from useEffect to useUpdateEffect, which prevents onChange from firing on initial mount/render (triggering updateBoostValue->unsavedChanges) @see https://github.com/streamich/react-use/blob/master/docs/useUpdateEffect.md
jenkins, test this (had to abort for Jenkins upgrade) |
Thanks Spencer!! |
💚 Build SucceededMetrics [docs]Module Count
Async chunks
To update your PR or re-run it, just comment with: |
👀 |
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 find with useUpdateEffect. Super clean fix, thank you.
* Fix unsavedChanges false positive when MultiInputRows is present - The fix for this is to change MultiInputRows from useEffect to useUpdateEffect, which prevents onChange from firing on initial mount/render (triggering updateBoostValue->unsavedChanges) @see https://github.com/streamich/react-use/blob/master/docs/useUpdateEffect.md * Fix precision tuner not triggering unsavedChanges
* Fix unsavedChanges false positive when MultiInputRows is present - The fix for this is to change MultiInputRows from useEffect to useUpdateEffect, which prevents onChange from firing on initial mount/render (triggering updateBoostValue->unsavedChanges) @see https://github.com/streamich/react-use/blob/master/docs/useUpdateEffect.md * Fix precision tuner not triggering unsavedChanges
…5091) * Fix unsavedChanges false positive when MultiInputRows is present - The fix for this is to change MultiInputRows from useEffect to useUpdateEffect, which prevents onChange from firing on initial mount/render (triggering updateBoostValue->unsavedChanges) @see https://github.com/streamich/react-use/blob/master/docs/useUpdateEffect.md * Fix precision tuner not triggering unsavedChanges Co-authored-by: Constance <constancecchen@users.noreply.github.com>
…5092) * Fix unsavedChanges false positive when MultiInputRows is present - The fix for this is to change MultiInputRows from useEffect to useUpdateEffect, which prevents onChange from firing on initial mount/render (triggering updateBoostValue->unsavedChanges) @see https://github.com/streamich/react-use/blob/master/docs/useUpdateEffect.md * Fix precision tuner not triggering unsavedChanges Co-authored-by: Constance <constancecchen@users.noreply.github.com>
Summary
This PR fixes 2 separate unsaved changes bugs. closes https://github.com/elastic/app-search-team/issues/1881
Bug 1: MultiInputRows causes an unsaved changes false positive (ddcc251)
AKA, the ghost of #96881 (comment) past 👻
MultiInputRows was causing an unsaved change false positive because its
onChange
fn (updateBoostValue
) was firing on mount.I did a quick search for more elegant ways to mimic the
componentDidUpdate
(i.e., sanscomponentDidMount
) lifecycle with React hooks, and as it turns out, thereact-use
library does exactly what we want, is used in Kibana, and is maintained by an Elastician (the awesome Vadim Dalecky). 🎉 Docs here: https://github.com/streamich/react-use/blob/master/docs/useUpdateEffect.mdBug 2: Precision Tuner not triggering unsaved changes (d51216a)
This is a super small/quick fix for precision tuner changes not triggering the unsaved changes prompt.
QA
Checklist
NB: I was pleasantly surprised
useUpdateEffect
worked as-is without any mocking required - huge kudos to the awesome folks & Elasticians writing/maintaining that library