Page MenuHomePhabricator

Implement `unload handlers` for compose
Closed, ResolvedPublic

Description

When closing a tab or navigating away from the page we should warn the user if they have unsaved changes. This is done with the onbeforeunload handler.

Event Timeline

ppelberg created this task.Dec 9 2019, 8:11 PM
Restricted Application added a subscriber: Aklapper. · View Herald TranscriptDec 9 2019, 8:11 PM
Esanders updated the task description. (Show Details)Dec 9 2019, 9:04 PM

Change 556204 had a related patch set uploaded (by Esanders; owner: Esanders):
[mediawiki/extensions/DiscussionTools@master] Add beforeunload handlers

https://gerrit.wikimedia.org/r/556204

Change 556204 merged by jenkins-bot:
[mediawiki/extensions/DiscussionTools@master] Add beforeunload handlers

https://gerrit.wikimedia.org/r/556204

matmarex added a project: Editing QA.
JTannerWMF moved this task from Inbox to High Priority on the Editing QA board.

@Esanders: I am getting this warning message from the browser when I am closing the tab without posting a reply that I typed. Also, while navigating away to the other tabs except "Edit Source" tab.

When I type a reply and click on "Edit Source" tab, it navigates away from the page without giving any warning.

Is it the correct behavior?

DLynch added a subscriber: DLynch.Feb 11 2020, 4:32 PM

My theory is that @Ryasmeen has NWE enabled, and so "edit source" isn't technically a navigation event (because it's just replacing the contents of the current page). We need to special case detecting and canceling this somehow.

@Ryasmeen If you don't have NWE enabled, let me know, because that'd demolish my theory. 😁

My theory is that @Ryasmeen has NWE enabled, and so "edit source" isn't technically a navigation event (because it's just replacing the contents of the current page). We need to special case detecting and canceling this somehow.

@Ryasmeen If you don't have NWE enabled, let me know, because that'd demolish my theory. 😁

@DLynch: You are right :) I had NWE enabled, this doesn't happen when switching to old wikitext editor.

ppelberg added a comment.EditedFeb 12 2020, 12:07 AM

@DLynch: You are right :) I had NWE enabled, this doesn't happen when switching to old wikitext editor.

Good spot, @DLynch.

We need to special case detecting and canceling this somehow.

David, can you describe this in a bit more detail? Does "special case detecting and cancelling" refer to writing a patch to make it so the browser displays a warning message [1] before contributors who a) have NWE enabled and b) have started writing a reply click "Edit source"?


  1. Browser warning message: "Leave site? / Changes you made may not be saved."

Yes.

Understood. If you have a task already written, please feel free to close this one as a duplicate: T244942

ppelberg closed this task as Resolved.Feb 12 2020, 9:40 PM
ppelberg claimed this task.
Restricted Application added a project: User-Ryasmeen. · View Herald TranscriptFeb 12 2020, 9:40 PM