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

[Embeddables Rebuild] Fix unsaved changes on new dashboards bug #184955

Conversation

Heenawter
Copy link
Contributor

@Heenawter Heenawter commented Jun 6, 2024

Closes #184174

Summary

This PR fixes the bug where, on a new and unsaved dashboard, adding both a legacy embeddable and an image embeddable would result in a dashboard getting stuck with unsaved changes on the first save. This was caused by a race condition - since the debounce on the React embeddable unsaved changes observable was before the switchMap, the React embeddable observable fired immediately on save which then triggered the diffingSubscription to fire too early.

Before:

Screen.Recording.2024-06-06.at.11.04.04.AM.mov

After:

Screen.Recording.2024-06-06.at.10.59.05.AM.mov

@Heenawter Heenawter added release_note:fix Team:Presentation Presentation Team for Dashboard, Input Controls, and Canvas loe:small Small Level of Effort impact:low Addressing this issue will have a low level of impact on the quality/strength of our product. project:embeddableRebuild labels Jun 6, 2024
@Heenawter
Copy link
Contributor Author

/ci

Comment on lines +121 to +131
return (async () => {
const {
explicitInput: currentInput,
componentState: { lastSavedInput },
} = this.getState();
getDashboardUnsavedChanges
.bind(this)(lastSavedInput, currentInput)
.then((unsavedChanges) => {
if (observer.closed) return;
observer.next(unsavedChanges);
});
});
const unsavedChanges = await getDashboardUnsavedChanges.bind(this)(
lastSavedInput,
currentInput
);
return unsavedChanges;
})();
Copy link
Contributor Author

@Heenawter Heenawter Jun 6, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Switched to return a promise rather than an observable - this is a stylistic change and has nothing to do with the actual bug.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for making this change. IMO it's much more obvious what's actually happening here when we use a promise

@kibana-ci
Copy link
Collaborator

💚 Build Succeeded

Metrics [docs]

Async chunks

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

id before after diff
dashboard 496.0KB 495.9KB -30.0B

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

@Heenawter Heenawter marked this pull request as ready for review June 6, 2024 18:21
@Heenawter Heenawter requested a review from a team as a code owner June 6, 2024 18:21
@elasticmachine
Copy link
Contributor

Pinging @elastic/kibana-presentation (Team:Presentation)

Copy link
Contributor

@ThomThomson ThomThomson left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! Code only review, as the fix makes sense.

@Heenawter Heenawter merged commit a4cd614 into elastic:main Jun 6, 2024
28 checks passed
@Heenawter Heenawter deleted the fix-react-embeddables-race-condition_2024-06-06 branch June 6, 2024 18:31
@kibanamachine kibanamachine added v8.15.0 backport:skip This commit does not require backporting labels Jun 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport:skip This commit does not require backporting impact:low Addressing this issue will have a low level of impact on the quality/strength of our product. loe:small Small Level of Effort project:embeddableRebuild release_note:fix Team:Presentation Presentation Team for Dashboard, Input Controls, and Canvas v8.15.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Dashboard] Unsaved changes after saving new dashboard with old and new embeddables
5 participants