Page MenuHomePhabricator

Add "are you sure you want to leave" when media info has unsaved changes
Open, Needs TriagePublicFeature

Description

Feature summary (what you would like to be able to do and where):
In T312315, this functionality was removed, because the implementation would sometimes trigger when leaving the page before the medaiinfo interface was finished loading. Additionally it was breaking forward/backward cache in some browsers.

Use case(s) (list the steps that you performed to discover that problem, and describe the actual underlying problem which you want to solve. Do not describe only a solution):
It is still good to have an "are you sure you want to leave" functionality, but it has to be implemented in a way that it is only active when an edit is actually in progress. The functionality should not be able to trigger and not occupy the onbeforeunload eventhandler, when people are NOT having an in-progress edit.

Benefits (why should this be implemented?):

See also: T55478: Add a confirmation dialog before closing the window when editing Wikidata

Event Timeline

As an alternative we can auto-save the things to edit automatically in IndexedDB (used by Edit Recovery, but need to generalize to support non-Wikitext edit mode). As a prospect I even supposed that core Edit Recovery should take over the current recovery feature in VisualEditor and DiscussionTools.

The purpose of the warning is actually twofold:

  • Avoid users losing their work by accidentally closing the tab, since if the tab is closed, the work is gone.
  • Avoid users losing their work by purposefully closing (and never re-opening) a tab on which they think all their work has been saved.

The purpose of auto-save is also twofold:

  • Avoid users losing their work by accidentally closing the tab, as the work is restored when they re-open the tab.
  • Avoid users losing their work due to power outage/browser freeze/etc., as the work is restored when they re-open the browser.

The first points match, but the second points don’t. So while auto-save could take over some jobs of the warning, not all (and conversely, while the warning helps in some situations where the auto-save would also help, not always). If auto-save is implemented first, it would be a huge improvement compared to the current situation, but the warning would still make sense.