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

[App Search] Relevance Tuning: Fix unsaved changes bug #104951

Merged
merged 2 commits into from
Jul 9, 2021

Conversation

cee-chen
Copy link
Contributor

@cee-chen cee-chen commented Jul 8, 2021

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., sans componentDidMount) lifecycle with React hooks, and as it turns out, the react-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.md

Bug 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

  • Go to any engine with documents
  • Go to the Relevance Tuning view
  • Create a value boost, enter any text. Save
  • Refresh the page (prompt should not appear)
  • Refresh the page again, a prompt should not appear
  • Navigate away from the page, a prompt should not appear
  • Go back to the Relevance Tuning view and change the precision slider setting
  • Navigate away from the page and confirm a prompt does appear

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

cee-chen added 2 commits July 8, 2021 10:39
- 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
@cee-chen cee-chen added bug Fixes for quality problems that affect the customer experience release_note:skip Skip the PR/issue when compiling release notes v7.14.0 auto-backport Deprecated - use backport:version if exact versions are needed v7.15.0 labels Jul 8, 2021
@cee-chen cee-chen requested review from byronhulcher and a team July 8, 2021 17:46
@spalger
Copy link
Contributor

spalger commented Jul 8, 2021

jenkins, test this

(had to abort for Jenkins upgrade)

@cee-chen
Copy link
Contributor Author

cee-chen commented Jul 8, 2021

Thanks Spencer!!

@kibanamachine
Copy link
Contributor

💚 Build Succeeded

Metrics [docs]

Module Count

Fewer modules leads to a faster build time

id before after diff
enterpriseSearch 1442 1444 +2

Async chunks

Total size of all lazy-loaded chunks that will be downloaded as the user navigates the app

id before after diff
enterpriseSearch 2.1MB 2.1MB +785.0B

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

@JasonStoltz JasonStoltz self-assigned this Jul 9, 2021
@JasonStoltz
Copy link
Member

👀

Copy link
Member

@JasonStoltz JasonStoltz left a 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.

@cee-chen cee-chen merged commit facaeb7 into elastic:master Jul 9, 2021
@cee-chen cee-chen deleted the relevance-tuning-unsaved-changes branch July 9, 2021 16:23
kibanamachine pushed a commit to kibanamachine/kibana that referenced this pull request Jul 9, 2021
* 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
kibanamachine pushed a commit to kibanamachine/kibana that referenced this pull request Jul 9, 2021
* 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
@kibanamachine
Copy link
Contributor

💚 Backport successful

Status Branch Result
7.14
7.x

The backport PRs will be merged automatically after passing CI.

kibanamachine added a commit that referenced this pull request Jul 9, 2021
…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>
kibanamachine added a commit that referenced this pull request Jul 9, 2021
…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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
auto-backport Deprecated - use backport:version if exact versions are needed bug Fixes for quality problems that affect the customer experience release_note:skip Skip the PR/issue when compiling release notes v7.14.0 v7.15.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants