Page MenuHomePhabricator

Warn users when they try to leave an in-progress section translation
Closed, ResolvedPublic

Description

Currently section translations are not saved until they are finally published. Thus, leaving the editor before publishing results in the contents being discarded without any signal.

This ticket proposes to show a warning when the user leaves the editor:

  • A system alert will be used for simplicity.
  • The alert will be shown only when the user has made a contribution to the translation. That is, if the user gets to an empty translation and leaves it without adding a sentence to it, the alert will not be shown.
  • The alert will be shown (when it applies) in reaction to any mechanism to leave the editor: back arrow, device/browser back button, closing the tab, etc.

Details for the alert:

Browsers provide default messaging:

Screenshot 2020-12-18 at 8.13.46 PM.png (160×430 px, 21 KB)


Once autosaving is supported in the future, the alert will be only shown when auto-save had not enough time to save all the changes (as it happens in Content Translation), and the text will be updated.

Event Timeline

@Pginer-WMF. Unfortunately custom messages are not supported for such alerts on modern browsers (https://stackoverflow.com/questions/38879742/is-it-possible-to-display-a-custom-message-in-the-beforeunload-popup). I believe that we can live with default messages.
This is how the default message looks like on Chrome:

Screenshot 2020-12-18 at 8.13.46 PM.png (160×430 px, 21 KB)

Additionally, since we have a single page application, "back" arrow navigates to the previous screen but the translation is not being lost. Should we display a warning message to these cases too?

Change 650557 had a related patch set uploaded (by Nik Gkountas; owner: Nik Gkountas):
[mediawiki/extensions/ContentTranslation@master] SX: Warn users before leave when in progress translation exists

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

@Pginer-WMF. Unfortunately custom messages are not supported for such alerts on modern browsers (https://stackoverflow.com/questions/38879742/is-it-possible-to-display-a-custom-message-in-the-beforeunload-popup). I believe that we can live with default messages.

Thanks for the clarification. Yes, the default works.

Additionally, since we have a single page application, "back" arrow navigates to the previous screen but the translation is not being lost. Should we display a warning message to these cases too?

The current situation can be prone to confusion since it is not clear how to get back to the translation and it may get lost with additional navigation/refresh. So I'm inclined to show the warning anyways. In this way we communicate the expectation to complete the translations (for now) in one session.

Later we can support persistence in a better way (showing the in-progress translations in the list to continue them later, and storing them persistently)

Change 650557 merged by jenkins-bot:
[mediawiki/extensions/ContentTranslation@master] SX: Warn users before leave when in progress translation exists

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

So I'm inclined to show the warning anyways.

@ngkountas I can't see the warning anywhere even when I go all the way to the "Select Section to Translate" screen.
At this moment I can't go anywhere else because the start of the translation is always my starting point since the dashboard is not working.
Is this expected or I should see the warning when leaving the section?
I noticed that the translation is never lost, if I go back to the section translated my changes are still there.

The warning shows up only when user has already translated at least one segment (title or sentence). I believe this is the expected behaviour. @Pginer-WMF is that right?

The warning shows up only when user has already translated at least one segment (title or sentence). I believe this is the expected behaviour. @Pginer-WMF is that right?

Yes. The idea is to warn about losing content only when there is content contributed by the user that can be lost.

the warning only shows when the windows/tab is about to be closed, not when I leave the translation.
closing this task since it seems to be the desired behaviour.

the warning only shows when the windows/tab is about to be closed, not when I leave the translation.

I think we were talking about two different aspects that are intersecting here. When there are changes, the warning is expected on both the tab close and the back arrow on top. When there are not changes, the warning should not be shown.

I created a table to illustrate which is the combination that needs adjustment:

Closing mechanismWith user changesWithout user changes
Tab closedWarning is shown (as expected)Warning is not shown (as expected)
Back arrow on topWarning is not shown (not expected)Warning is not shown (as expected)

I'm moving to the quarter backlog since the remaining part is not that urgent compared to the planned immediate work.

Question: the warning should be shown even when user tries to go from "Pick a sentence" to "Compare the contents" step (translation is not being lost) or when the user goes back all the way to dashboard (in this case the translation will actually be lost)?

Question: the warning should be shown even when user tries to go from "Pick a sentence" to "Compare the contents" step (translation is not being lost) or when the user goes back all the way to dashboard (in this case the translation will actually be lost)?

It will be shown when user tries to go from "Pick a sentence" to "Compare the contents" step. Technically the contents are not lost, but they are also not persisted and we provide no indication of continuity (e.g., a draft translation being there for such section).
Once we support persistence we would be able to provide a much fluent experience (and these warnigns would be reused to shown only when auto-saving is in progress).

Suppose a user enters "Pick a sentence" step, translates a couple sentences, then go back to "Compare contents" step, checks something they need, then go back again to "Pick a sentence". At that point the translation will be as the user left it. So we may need to actually reset the translation in such cases, so that there is no mismatch between messages and application behavior.

Suppose a user enters "Pick a sentence" step, translates a couple sentences, then go back to "Compare contents" step, checks something they need, then go back again to "Pick a sentence". At that point the translation will be as the user left it. So we may need to actually reset the translation in such cases, so that there is no mismatch between messages and application behavior.

Reseting would be ideal if it does not require much coding effort. I just wanted to make sure we don't spend time on an area that will change later.

@RodneyAraujo as pointed in T270484#6702176 the alert messages when leaving the page are provided by the browser. I appreciate a lot your feedback and suggestions, but please do not edit the task descriptions without a discussion in the comments sections first. Thanks!

Change 905576 had a related patch set uploaded (by Nik Gkountas; author: Nik Gkountas):

[mediawiki/extensions/ContentTranslation@master] SX: Add confirmation dialog on back button click

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

Change 905576 merged by jenkins-bot:

[mediawiki/extensions/ContentTranslation@master] SX: Add confirmation dialog on back button click

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

Change 907436 had a related patch set uploaded (by Nik Gkountas; author: Santhosh):

[mediawiki/extensions/ContentTranslation@master] CX3 Build 0.2.0+20230410

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

Change 907436 merged by jenkins-bot:

[mediawiki/extensions/ContentTranslation@master] CX3 Build 0.2.0+20230410

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