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

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

@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?

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.

@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 claimed this task.