Page MenuHomePhabricator

VisualEditor: Template editing dialog hijacks Ctrl+backspace
Closed, ResolvedPublic2 Estimated Story PointsBUG REPORT

Description

List of steps to reproduce (step by step, including full links if applicable):

  • Edit a page in VisualEditor
  • Open an existing template for editing
  • Type something in some template data field
  • Press Ctrl+backspace

What happens?:
The field is removed (same as if you clicked on the little trash icon above it)

What should have happened instead?:
The last word in the textarea is deleted

Software version (if not a Wikimedia wiki), browser information, screenshots, other information, etc.:
Chrome 98 on Ubuntu 20.04.
The specific article and template where I encountered this is https://wikitech.wikimedia.org/wiki/Deployments -> edit "Wednesday, February 16" section -> "21:00–22:00 UTC, UTC late backport window" template -> "Changes" field.

Acceptance criteria:

  • Make Ctrl+Backspace work only on Mac, not on PC.
  • Change the keyboard event handler so it doesn't do anything when the shortcut was pressed with the focus being in an <input> or <textarea>.
  • For consistency, change the Ctrl+Shift+Up/Down shortcuts the same way.
  • Make sure all 4 Ctrl+Shift+Left/Right/Up/Down can be used in text fields without triggering unexpected behavior.
  • No update to the help page needed.

Event Timeline

Looks like this was deliberately done by @WMDE-Fisch in T300971.

Not having discussed this in detail with the rest of the team, here is what I think:

  • First quick-fix is to disable Ctrl+Backspace on PC. It was meant to work only on Mac.
  • On Mac it seems to be appropriate to use Cmd+Backspace. Here is a good source I found: https://superuser.com/q/482771.
  • On PC both Ctrl+Backspace as well as Ctrl+Del are widely available but not well known hotkeys to delete an entire word. I use them myself very, very regularly.
  • However, it's still ok to use Ctrl+Del for what we want it to do as long it only does that when the focus is not in an input field. Coincidentally this was the case before T300971.
  • So one solution is to change the hotkeys (probably all 3 up/down/delete to make them behave consistent) to not do anything when they realize the keypress was done in an input/textarea. I think this is possible using the sender information from the event object.
  • Another solution is to switch to Ctrl+Shift+Del.
  • So one solution is to change the hotkeys (probably all 3 up/down/delete to make them behave consistent) to not do anything when they realize the keypress was done in an input/textarea. I think this is possible using the sender information from the event object.

We just decided for that option in the bigger round.

On Mac it seems to be appropriate to use Cmd+Backspace. Here is a good source I found: https://superuser.com/q/482771.

I think on Mac you're fine so long as you don't take [option/alt]+backspace, which is what's used for delete-a-word.

Change 766114 had a related patch set uploaded (by Svantje Lilienthal; author: Svantje Lilienthal):

[mediawiki/extensions/VisualEditor@master] Added check for hotkey action on input or textareas

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

We made a patch that disables the keypress actions in textareas and input fields. Is this sufficient or do we still need to remove the backspace action for PC users as well, @Lena_WMDE? It is an easy change, I am only wondering if it really is necessary. 🤔

On PC, backspace is not a synonym for the delete key, and typically not used as a hotkey like the one we have here. We implemented it exclusively for Mac because there are actually Mac machines that don't have a delete key. Because of this the usage as a hotkey is much more common on Mac. But not on PC. Having it enabled on PC was a mistake. (More precisely, we decided to go with simpler code because "how can it hurt", but as it turned out it can.)

Ok, I adjusted the patch accordingly.

We implemented this ticket as requested. But now this issue appears:

You can not delete a wikitext element with focusing it via mouse and then using ctrl+del, because the focus automatically jumps to the input area.

You can still delete it though using the trash icon button in the toolbar and also use the keycombi when the element is being focused via tab.

That's a follow-up question for demo time. Let's merge this first.

Generally speaking, the hotkeys are mostly for keyboard users. These typically don't click the elements in the sidebar the way you did in your example.

Deleting a wikitext element is still possible by simply emptying the wikitext field.

Change 766114 merged by jenkins-bot:

[mediawiki/extensions/VisualEditor@master] Added check for hotkey action on input or textareas

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

WMDE-Fisch moved this task from Demo to Done on the WMDE-TechWish-Sprint-2022-03-02 board.