[Embeddable Rebuild] Fix stuck unsaved changes#190165
Merged
Heenawter merged 8 commits intoelastic:mainfrom Aug 12, 2024
Merged
[Embeddable Rebuild] Fix stuck unsaved changes#190165Heenawter merged 8 commits intoelastic:mainfrom
Heenawter merged 8 commits intoelastic:mainfrom
Conversation
Contributor
Author
|
/ci |
7dac049 to
ebc3b4d
Compare
Contributor
Author
|
/ci |
f6bc372 to
bc10479
Compare
bc10479 to
e20c427
Compare
Contributor
Author
|
/ci |
Contributor
|
Pinging @elastic/kibana-presentation (Team:Presentation) |
nreese
reviewed
Aug 9, 2024
...resentation/presentation_containers/interfaces/unsaved_changes/initialize_unsaved_changes.ts
Outdated
Show resolved
Hide resolved
2cab20a to
fabd6be
Compare
💛 Build succeeded, but was flaky
Failed CI StepsMetrics [docs]Async chunks
Page load bundle
History
To update your PR or re-run it, just comment with: cc @Heenawter |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #190066
Summary
In #189128 (comment), I suggested adding a
skipto the comparators subscription in order to preventunsavedChangesfrom emitting twice - however, while I was on the right track with this suggestion, I didn't look closely enough at how this worked. Essentially, this is how it worked without the skip when creating a brand new React embeddable:unsavedChangesby callingrunComparatorsto get its initial value - since it is a new embeddable and therefore does not have unsaved state, it returns the entire state per the early return inrunComparatorsunsavedChangesgets set again by callingrunComparators- similarly, it returns the entire state due to the early return.By adding the
skipwhere I suggested, this is what happened:unsavedChangesby callingrunComparatorsto get its initial value - it returns the entire state due to the early return.skip- this is good, because unsaved changes emits only once!skipmade it so that the subscription did not fire whenlastSavedStateemits - it is waiting for the comparators to emit again before firing! So, the unsaved changes remains unnecessarily 🔥Essentially, we want to
skipthe first emit of the wholecomparator+lastSavedStateobservable that results from thepipe- not just the comparators. Otherwise, we don't get to thecombineLatestWithuntil after the comparators emit a second time, which means we don't respond whenlastSavedStateemits after a React embeddable panel is freshly added. By rearranging the order of operations in thepipe, we achieve the desired behaviour.To test the above, move the
skipto before thelastSavedStateemit. Add a React embeddable panel, and try to save - unsaved changes will be stuck. On a fresh dashboard, add a React embeddable panel again, edit that React embeddable to trigger a comparator emit, then save - unsaved changes is cleared!Checklist
For maintainers