Page MenuHomePhabricator

VisualEditor: "Discard edits" should not be focused by default in the AbandonEditDialog
Closed, ResolvedPublic

Description

When going out of the VisualEditor (either by clicking elsewhere or by hitting escape) the AbandonEditDialog offers two options: "Cancel" and "Discard edits". The "Discard edits" option is focused by default and so the user only has to hit Enter or Space to confirm that they want their edits discarded.

Far too often this results in edits accidentally being discarded, with no way of recovering them as VisualEditor's AutoSave is cleared when edits are discarded.

Two hypothetical situations where one will encounter this problem:

  • You are writing an article with VisualEditor and you are changing the target of a link or changing a citation. You decide not to change it after all so you click Escape. Unaware that you held the Escape button a few milliseconds to long or accidentally double clicked it (causing a AbandonEditDialog to fire), you continue writing. Words are short, you don't notice you havent exited the AbandonEditDialog, and you hit the Space bar. Poof, your work is gone and no way of retrieving it.
  • You are writing an article with VisualEditor and you somehow click out of it. The AbandonEditDialog pops up and you, having used Apple computers for decades, know intuitively that the "Yes" button will be activated with Enter and the "Cancel" button will be activated with Space. You click Space without giving it much thought, and your edits are discarded.

Expected results:
Clicking Space should not cause edits to be discarded.

Is this really necessary to change?
Yes, I have lost many a large edit to this unexpected behaviour, and I assume this may be the cause of many editors at the Wikipedia Help Desk coming and asking "I don't know what I clicked in the VisualEditor but my work is gone".

Event Timeline

I've uploaded a patch for this. The change removes the focus from the "Discard edits" button. It does however also give the button a red text and gray background instead of white text with red background.

Change 587878 had a related patch set uploaded (by Gerrit Patch Uploader; owner: Þjarkur):
[mediawiki/core@master] T249880 – VisulEditor: Removing default focus on "Discard edits" in the AbandonEditDialog

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

Sorry for the late response.

Note that this change has some additional consequences:

  • Changing the default action also changes the appearance of the buttons:
BeforeAfter
en.wikipedia.org_wiki_The_Fighting_Temeraire(Laptop with small screen).png (576×1 px, 215 KB)
en.wikipedia.org_wiki_The_Fighting_Temeraire(Laptop with small screen) (1).png (576×1 px, 214 KB)
  • We use the same dialog elsewhere, so the change will also apply to MobileFrontend and to DiscussionTools

I think this is fine, and I'm convinced by your explanation. Thanks for the patch!

Change 587878 had a related patch set uploaded (by Bartosz Dziewoński; owner: Þjarkur):
[mediawiki/core@master] Removing default focus on "Discard edits" in the AbandonEditDialog

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

Change 587878 merged by jenkins-bot:
[mediawiki/core@master] Removing default focus on "Discard edits" in the AbandonEditDialog

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

Note that this change has some additional consequences:

I think the full red button did a better job of conveying the destructive nature of the action. cc @iamjessklein @Volker_E

I think upstream in OOUI we should change the default focus to not be the "primary" action if the primary action is destructive.

Note that this change has some additional consequences:

I think the full red button did a better job of conveying the destructive nature of the action. cc @iamjessklein @Volker_E

+1.

Note that this change has some additional consequences:

  • Changing the default action also changes the appearance of the buttons:
  • @matmarex, how can we implement the change in focus (from "Discard edits" to "Continue editing") without also changing the treatment of the "Discard edits" button? Is it to do what Ed is describing below?

I think upstream in OOUI we should change the default focus to not be the "primary" action if the primary action is destructive.

In T249880#6179336, @Esanders wrote:
I think upstream in OOUI we should change the default focus to not be the "primary" action if the primary action is destructive.

I disagree. This is already an extra dialog window that opens up to pause the user's action and give another hint and another moment of consideration. The focus should be the primary action. If the product owners think that the destructive action is not a primary action, the dialog should use a different configuration resembling such action balance accordingly.

  • @matmarex, how can we implement the change in focus (from "Discard edits" to "Continue editing") without also changing the treatment of the "Discard edits" button? Is it to do what Ed is describing below?

I think upstream in OOUI we should change the default focus to not be the "primary" action if the primary action is destructive.

We could also implement this behavior for this dialog only; but I'm not sure if it would actually be better, especially considering that T255443 asks to make this dialog less "aggressive", which is what we actually did (by accident).

In T249880#6179336, @Esanders wrote:
I think upstream in OOUI we should change the default focus to not be the "primary" action if the primary action is destructive.

I disagree. This is already an extra dialog window that opens up to pause the user's action and give another hint and another moment of consideration. The focus should be the primary action. If the product owners think that the destructive action is not a primary action, the dialog should use a different configuration resembling such action balance accordingly.

Our 'primary' flag is overloaded, in that visually it means it should take a stronger appearance to draw the user's attention. But in dialogs is also means that is should take focus to be the 'default' action. I think for destructive actions these two definitions will often be in conflict.

It should be possible to give initial focus to a non-primary action without losing the primary styling (indeed forms do not auto-focus the primary submit button).

The issue as written was resolved by T249880#6174763. If you still feel strongly about button colors, please open another task.