Page MenuHomePhabricator

Show toast notification when restoring edit data
Closed, ResolvedPublicFeature

Assigned To
Authored By
Samwilson
Jul 26 2023, 5:20 AM
Referenced Files
F41478947: 2023-11-09_11-06-11.png
Nov 9 2023, 7:10 PM
F41478949: 2023-11-09_11-08-25.png
Nov 9 2023, 7:10 PM
F41474154: 2023-11-08_11-56-23.png
Nov 8 2023, 10:57 PM
F41474152: 2023-11-08_11-53-43.png
Nov 8 2023, 10:57 PM
F41474146: 2023-11-08_11-49-05.png
Nov 8 2023, 10:57 PM
F41474140: 2023-11-08_11-41-28.png
Nov 8 2023, 10:57 PM
F41474161: 2023-11-08_13-44-40.png
Nov 8 2023, 10:57 PM
F41474158: 2023-11-08_11-50-17.png
Nov 8 2023, 10:57 PM

Description

When restoring page edit data a visual notification should be shown above the edit form (e.g. where the "you're not logged in" banner is shown) notifying users that the form contents that they're seeing has been restored from the saved version and is not the current page data.

The notification should have the title "Changes recovered" and text "Your unsaved changes have been automatically recovered." This is the text that VisualEditor uses in the same situation.

It should also have the option of un-restoring, and returning to the actual page data. Un-restoring should delete the restored data (because the user is declaring that they no longer want it).

The primary action in the notification should be to 'show changes', which opens the diff. This should work equally well when live preview is enabled.

Dismissing the notification can be done by clicking it or discarding the changes.

QA Results - Beta

Event Timeline

Restricted Application added a subscriber: Aklapper. · View Herald Transcript

@JSengupta-WMF I and @tstarling were talking about the restore behaviour, and thought we'd open this ticket to talk about what this part of the feature should look like (or to confirm that it's not wanted, if that is the case).

Joy and I had a meeting about this yesterday, and came up with a few thoughts:

VE uses a notification toast when it restores an edit, with the title "Changes recovered" and text "Your unsaved changes have been automatically recovered."
It also shows a modal dialog when the page has been edited in the meantime (although we noticed this seemed to also happen sometimes for a new page, which might be a bug), with the title "Resume edit" and text "This page was edited since you last loaded it. Would {{GENDER:|you}} like to resume {{GENDER:|your}} edit of the old version, or start a new edit of the latest version?"

One idea is to start with this simplest form of notification, which is the mw.notify toast, and use the same wording as VE.

Another idea was to default to not loading recovery data, but explicitly asking the user (probably via a modal dialog). This might also be annoying, depending on how often people return to an in-progress page (data about which we do not have at the moment). It raises the idea of adding an 'undo' button to revert the recovery (it may not be immediately obvious that 'Cancel' will discard the recovery data).

The prompt that editors currently get when leaving an in-progress edit (a browser-provided prompt; usually something like "This page is asking you to confirm that you want to leave — information you’ve entered may not be saved.") could perhaps become unnecessary if the edit recovery process is reliable. We are not yet comfortable with the reliability, but this could be investigated in the future.

Samwilson renamed this task from Add banner above form when restoring edit data to Show toast notification when restoring edit data.Sep 29 2023, 9:00 AM
Samwilson updated the task description. (Show Details)

I've been using edit recovery on my local for a while now and it works amazingly well! Almost too well… Whenever I do some test editing without saving (which isn't unusual for me even in prod), I may want to discard those edits, to sort of start with a clean slate.

Another idea was to default to not loading recovery data, but explicitly asking the user (probably via a modal dialog). This might also be annoying, depending on how often people return to an in-progress page (data about which we do not have at the moment). It raises the idea of adding an 'undo' button to revert the recovery (it may not be immediately obvious that 'Cancel' will discard the recovery data).

That sounds perfect! My guess is users will generally prefer to always have content auto-restored (I certainly have come to love it), but occasionally they'll want to discard and start anew.

Un-restoring should delete the restored data (because the user is declaring that they no longer want it).

Also agreed.

Change 965051 had a related patch set uploaded (by Samwilson; author: Samwilson):

[mediawiki/core@master] Edit Recovery: Add notification when restoring data

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

Is 'Undo' the right phrase to use for the button in the toast? i.e.:

Screenshot 2023-10-11 at 15-46-57 Editing Lorem - Dev wiki1.png (151×284 px, 8 KB)

Or 'Revert' or 'Restore original' or something else?

There's a bug with the above patch when undoing to an empty textbox1 (e.g. when it's a new page). This looks like it's a Firefox bug (demo here).

But other than that it's getting close I think.

@Samwilson when user clicks on Undo, does it load the latest version of the article? Maybe 'Edit current version" would be a better CTA in that case.

when user clicks on Undo, does it load the latest version of the article?

No, not always the latest — we still need to figure out what to do about old revisions: T347867: Should we support Edit Recovery for old revisions?

Based on the call among Sam, Tim and Joy on 2023.10.18 it's decided that the notification will have two CTAs

  1. "Show changes" [White button with no icon] (will show a diff between editor's changes and the current version)
  2. "Discard changes" [Red link] (will revert to the current version)

I don't know how many languages will render these short enough to fit both on one line, but if they do it'll look like this:

Short labelsLong labels
Screenshot 2023-10-18 at 14-16-40 Editing Test - Dev wiki1.png (143×277 px, 8 KB)
Screenshot 2023-10-18 at 14-23-52 Editing Test - Dev wiki1.png (175×274 px, 11 KB)

Let's keep it in two lines so. Some examples -

German: Änderungen anzeigen / Änderungen verwerfen
Finnish: Näytä muutokset / Hylkää muutokset
Czech: Zobrazit změny / Vyřazení změn

Sure! Done.

I think this is all ready for review now then.

While reviewing this, it occurred to me that we might need a confirm for Discard changes? Currently if you click on it, which can happen accidentally, the changes are gone.

Good point about the confirmation step. I think we should merge the patch without that though, and then add it in a separate change. (This one is getting big enough.)

I'll sort out the issue that you found about it re-saving the original data after discardment.

Let's keep it in two lines so. Some examples -

German: Änderungen anzeigen / Änderungen verwerfen
Finnish: Näytä muutokset / Hylkää muutokset
Czech: Zobrazit změny / Vyřazení změn

Interestingly, this time German isn’t the longest one; Hungarian is even longer (or at least I can’t come up with a shorter translation):

"edit-recovery-loaded-title": "Változtatások helyreállítva",
"edit-recovery-loaded-message": "Az elmentetlen változtatásaidat automatikusan helyreállítottuk.",
"edit-recovery-loaded-show": "Változtatások megtekintése",
"edit-recovery-loaded-discard": "Változtatások elvetése",

And it’s not only longer, it’s too long: the show changes button isn’t centered.

Hungarian edit recovery popup.png (167×280 px, 15 KB)

I’m not sure how to fix this visual glitch, but it would be good to do something about it.

Change 965051 merged by jenkins-bot:

[mediawiki/core@master] Edit Recovery: Add notification when restoring data

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

I’m not sure how to fix this visual glitch, but it would be good to do something about it.

Thanks for finding this issue! It's because buttons have white-space: nowrap, which results in the button extending off the side of the notification box. I think the best fix is to wrap the text (rather than widen the notification box), e.g.:

Screenshot 2023-11-06 at 14-45-46 Editing Main Page - Dev wiki1.png (200×291 px, 14 KB)

Change 971634 had a related patch set uploaded (by Samwilson; author: Samwilson):

[mediawiki/core@master] Edit Recovery: Wrap text in notification popup buttons

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

@Samwilson Thanks for the patch! It fixes Hungarian, but it doesn’t help languages that use one extra long word. I don’t know whether such languages exist, though.

Ah good point, we can add hyphens:auto as well; I'll do that now.

With hyphens:Without:
Screenshot 2023-11-06 at 18-20-44 Editing Main Page - Dev wiki1.png (192×278 px, 14 KB)
Screenshot 2023-11-06 at 18-22-02 Editing Main Page - Dev wiki1.png (187×279 px, 14 KB)

(I just threw in a string of loremipsums to force it to be long. I couldn't find a language with such a long word there, but I agree that we should handle it.)

Change 971634 merged by jenkins-bot:

[mediawiki/core@master] Edit Recovery: Wrap text in notification popup buttons

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

hyphens:auto isn’t 100% safe either (what if the browser doesn’t know how to hyphenate the given language, or the word simply cannot be hyphenated?), and on the other hand (at least IMHO) makes the popup look worse when it wasn’t necessary, as it causes the text to be hyphenated even if it could fit in two lines without hyphenating (i.e. only breaking at spaces).

Hungarian edit recovery popup hyphenated.png (186×274 px, 13 KB)

Maybe the hyphenation should be reverted and only white-space:nowrap should be considered good enough unless and until we find a language in which it doesn’t help avoiding the overflow.

Samwilson added a subscriber: GMikesell-WMF.

Yeah that makes sense. I guess hyphenation is really more a prose feature than something we'd normally want in a button. Shall remove that CSS.

Also, in T347869#9311185, @GMikesell-WMF points out that the scroll location isn't preserved when discarding edit recovery, so I'll get that fixed too.

Change 972086 had a related patch set uploaded (by Samwilson; author: Samwilson):

[mediawiki/core@master] Edit Recovery: Remove hyphenation from button labels

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

@GMikesell-WMF I'm not able to replicate the bottom-scrolling bug. I'm editing the Dingo article as you mention, but when I discard the changes it correctly scrolls to the top (which is what this line of code is meant to be doing). Can you help me narrow this down (browser, page size, other gadgets etc.)?

Change 972086 merged by jenkins-bot:

[mediawiki/core@master] Edit Recovery: Remove hyphenation from button labels

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

@Samwilson

@GMikesell-WMF I'm not able to replicate the bottom-scrolling bug. I'm editing the Dingo article as you mention, but when I discard the changes it correctly scrolls to the top (which is what this line of code is meant to be doing). Can you help me narrow this down (browser, page size, other gadgets etc.)?

Device: MBA w/M2
OS: Sonoma: 14.0
Browser: Chrome 119
Skin: Vector 2022
Test link used: **https://en.wikipedia.beta.wmflabs.org/w/index.php?title=Dingo&action=edit&undo=605824&undoafter=605823**

@Samwilson "Show changes" opens the Diff and "Discard changes", dismisses the notification, and changes. I did have a couple of questions in the possible issue section if you don't mind checking it out, thanks!

Status: ✅ PASS
Environment: Beta: 1.42.0-alpha (f869de7)
OS: macOS Sonoma 14.0
Browser: Chrome 119, Firefox 119, Safari 17.0
Skins. Vector 2022, 2010, Minerva, Monobook, Timeless
Device: MBA M2
Emulated Device:: n/a
Test Links:
https://en.wikipedia.beta.wmflabs.org/w/index.php?title=Dingo&action=edit&undo=605824&undoafter=605823

✅AC1: https://phabricator.wikimedia.org/T342721

Browsers

ChromeFirefoxSafari
2023-11-09_11-08-25.png (1×2 px, 555 KB)
2023-11-09_11-06-11.png (1×2 px, 451 KB)
2023-11-08_14-40-11.png (1×2 px, 304 KB)

Different Languages

RTLDeHeHu
2023-11-08_11-39-48.png (1×1 px, 325 KB)
2023-11-08_11-44-41.png (1×2 px, 386 KB)
2023-11-08_11-50-17.png (1×2 px, 345 KB)
2023-11-08_13-44-40.png (1×2 px, 652 KB)

Possible issues❓

Language mix= Is it okay to have half a language (ex. Spanish/Korean) and the other half in English in the popup notification?

EsKo
2023-11-08_11-41-28.png (1×2 px, 362 KB)
2023-11-08_11-49-05.png (1×2 px, 343 KB)

Notification- Should this popup notification be movable since it gets in the way of menu selections like Vector 2022 and Timeless Skins? I mean you can always click on the notification to dismiss it and reload the page to bring it back too.

Vector 2022Timeless
2023-11-08_11-53-43.png (1×2 px, 660 KB)
2023-11-08_11-56-23.png (1×3 px, 779 KB)

Possible issues❓

Language mix= Is it okay to have half a language (ex. Spanish/Korean) and the other half in English in the popup notification?

EsKo
2023-11-08_11-41-28.png (1×2 px, 362 KB)
2023-11-08_11-49-05.png (1×2 px, 343 KB)

Notification- Should this popup notification be movable since it gets in the way of menu selections like Vector 2022 and Timeless Skins? I mean you can always click on the notification to dismiss it and reload the page to bring it back too.

Vector 2022Timeless
2023-11-08_11-53-43.png (1×2 px, 660 KB)
2023-11-08_11-56-23.png (1×3 px, 779 KB)

@Samwilson You can scratch this part. Found out about the translation and nothing we can do with the notification popup. I will move this to Done. Thanks for all your work!

Thanks @GMikesell-WMF sounds good.

Do we need to make a separate task for the bottom-scroll issue?