Closed Bug 1575576 Opened 7 years ago Closed 6 years ago

Emacs style keybindings on macOS don't work in elements with contenteditable attribute set

Categories

(Core :: DOM: Editor, defect, P3)

68 Branch
defect

Tracking

()

RESOLVED DUPLICATE of bug 1502005

People

(Reporter: dev, Unassigned)

Details

User Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.14; rv:68.0) Gecko/20100101 Firefox/68.0

Steps to reproduce:

  1. Visit a site with an element that has the contenteditable attribute set.
  2. Type Alt-F or Alt-B

Actual results:

The cursor did not move forward and backward by words as expected on macOS and doesn't respect DefaultKeyBinding.dict. This behaviour does happen on inputs and was fixed in 282097.

Expected results:

The element should respect DefaultKeyBinding.dict and move the cursor accordingly.

I've noticed that it only seems to be an issues for keybindings that begin with Option (ie the alt key).

For example, these don't work:

{
/* Additional Emacs bindings /
"~f" = "moveWordForward:"; /
M-f /
"~b" = "moveWordBackward:"; /
M-b /
"~<" = "moveToBeginningOfDocument:"; /
M-< /
"~>" = "moveToEndOfDocument:"; /
M-> /
"~v" = "pageUp:"; /
M-v /
"~d" = "deleteWordForward:"; /
M-d */
}

Could you please provide an example of a site with an element that has the contenteditable attribute set?
Thanks.

Flags: needinfo?(dev)

Sure, here is a page where you can verify the behaviour.

Here is a demo of the issues: https://ams3.digitaloceanspaces.com/lpd/bugs/bugzilla-1575576-demo.gif

Flags: needinfo?(dev)

Thanks for the demo and for the test page.
I couldn't manage to reproduce this issue, a character is insert in "Input/Textarea/Content editable" when i press "Option+f/b" and the cursor isn't moved forward and backward.
I'll assign "Core: Editor" component for it.

Component: Untriaged → Editor
Product: Firefox → Core

Thanks for trying to reproduce the issue.

You may need to create a DefaultKeyBinding.dict file in ~/Library/KeyBindings/. (Apple documentation is here)

The contents can be:

/* ~/Library/KeyBindings/DefaultKeyBinding.dict */

{
"~f" = "moveWordForward:"; /* M-f /
"~b" = "moveWordBackward:"; /
M-b */
}

You might have to log out and in again although I can appreciate that's annoying to do.

This works in Google Chrome and Safari and in the input and textarea which is why I think it's a bug. I can see there is a TextInputListener::HandleEvent that seems to be involved in translating native key bindings so maybe that's not responding correctly when contenteditable is set?

I use Slack and they use contenteditable a lot which is how I came across this.

Priority: -- → P3

I can reproduce this too.

Custom keybindings work as expected in:

  • The URL bar
  • Single line input fields
  • <textareas> (such as the bugzilla comment field)

They do not work as expected in blocks that have contenteditable=true, such as comment fields on Reddit, Gmail. Chrome and Safari work as expected.

Status: UNCONFIRMED → RESOLVED
Closed: 6 years ago
Resolution: --- → DUPLICATE
You need to log in before you can comment on or make changes to this bug.