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

fix(editor): Prevent unloading when changes are pending in new canvas (no-changelog) #10474

Conversation

alexgrozav
Copy link
Member

Summary

Screen.Recording.2024-08-19.at.14.42.22.mov

Related Linear tickets, Github issues, and Community forum posts

https://linear.app/n8n/issue/N8N-7587/weve-lost-the-warning-when-trying-to-close-the-tab-and-there-are

Review / Merge checklist

  • PR title and summary are descriptive. (conventions)
  • Docs updated or follow-up ticket created.
  • Tests included.
  • PR Labeled with release/backport (if the PR is an urgent fix that needs to be backported)

@alexgrozav alexgrozav self-assigned this Aug 19, 2024
@n8n-assistant n8n-assistant bot added n8n team Authored by the n8n team ui Enhancement in /editor-ui or /design-system labels Aug 19, 2024
*/

function onBeforeUnload(e: BeforeUnloadEvent) {
if (isDemoRoute.value || window.preventNodeViewBeforeUnload) {
Copy link
Contributor

Choose a reason for hiding this comment

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

What's this preventNodeViewBeforeUnload flag? I don't see it being set anywhere in the code

Copy link
Member

Choose a reason for hiding this comment

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

it's used in the e2e tests to skip this prompt

@@ -1410,6 +1427,10 @@ onBeforeMount(() => {
}
});

onActivated(() => {
window.addEventListener('beforeunload', onBeforeUnload);
Copy link
Contributor

Choose a reason for hiding this comment

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

Shouldn't we remove this listener also when this component is unmounted?

* Unload
*/

function onBeforeUnload(e: BeforeUnloadEvent) {
Copy link
Member

Choose a reason for hiding this comment

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

Could we extract this stuff into a useBeforeUnload composable, instead of duplicating this code?

tomi
tomi previously approved these changes Aug 21, 2024
Copy link
Contributor

@tomi tomi left a comment

Choose a reason for hiding this comment

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

Looks good, just one comment about documentation and a question

onUnload() {
// This will fire if users decides to leave the page after prompted
// Clear the interval to prevent the notification from being sent
clearTimeout(this.unloadTimeout);
Copy link
Contributor

Choose a reason for hiding this comment

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

This timeout is no longer cleared. Is that intentional?

Copy link
Member Author

Choose a reason for hiding this comment

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

It's cleared but not set anywhere in the code. I assume it's leftover code from another past change.

Copy link
Contributor

@tomi tomi left a comment

Choose a reason for hiding this comment

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

Thank you for addressing the feedback 💟 LGTM now 🚀

Copy link

cypress bot commented Aug 21, 2024



Test summary

413 0 0 0Flakiness 0


Run details

Project n8n
Status Passed
Commit fe46b56
Started Aug 21, 2024 9:57 AM
Ended Aug 21, 2024 10:02 AM
Duration 04:47 💡
OS Linux Debian -
Browser Electron 118

View run in Cypress Cloud ➡️


This comment has been generated by cypress-bot as a result of this project's GitHub integration settings. You can manage this integration in this project's settings in the Cypress Cloud

Copy link
Contributor

✅ All Cypress E2E specs passed

@alexgrozav alexgrozav merged commit 6d82fb9 into master Aug 21, 2024
33 checks passed
@alexgrozav alexgrozav deleted the n8n-7587-weve-lost-the-warning-when-trying-to-close-the-tab-and-there branch August 21, 2024 10:46
@janober
Copy link
Member

janober commented Aug 21, 2024

Got released with [email protected]

MiloradFilipovic added a commit that referenced this pull request Aug 22, 2024
* master:
  🚀 Release 1.56.0 (#10502)
  fix(editor): Sending 'Assistant session started event' to posthog (no-changelog) (#10500)
  fix(core): Use class-validator with XSS check for survey answers (#10490)
  fix(editor): Stop telemetry from triggering when initializing workflow in new canvas (no-changelog) (#10492)
  fix(AI Transform Node): Remove prompt as it's already set in ASK AI endpoint (no-changelog) (#10496)
  fix(editor): Prevent unloading when changes are pending in new canvas (no-changelog) (#10474)
  feat(core): Upgrade axios to address CVE-2024-39338 (no-changelog) (#10494)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
n8n team Authored by the n8n team Released ui Enhancement in /editor-ui or /design-system
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants