Open Bug 1289880 Opened 8 years ago Updated 2 years ago

Cursor move with arrow keys doesn't change the focus of nested contenteditable

Categories

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

47 Branch
defect

Tracking

()

UNCONFIRMED

People

(Reporter: ian, Unassigned)

References

(Blocks 1 open bug)

Details

(Keywords: parity-chrome, Whiteboard: [h2review-noted])

Attachments

(2 files)

User Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_10_5) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/51.0.2704.106 Safari/537.36

Steps to reproduce:

If you have a DOM structure that looks like:

  <div contenteditable="true">
    <div contenteditable="false">
      <div contenteditable="true">
        <!-- Cursor is here. -->
      </div>
    </div>
  </div>




Actual results:

The outer <div contenteditable="true"> will be the one with :focus, instead of the inner one. Which means it's impossible to style the inner <div> based on it having focus.


Expected results:

The inner <div contenteditable="true"> should be the one with :focus instead. Safari and Chrome both get this right.
Actually, an update (I can't seem to edit the previous comment):

If you click on the inner <div contenteditable="true"> to set the cursor there, the :focus will correctly be set as the inner element.

However, if you use the arrow keys to position the cursor to the inner <div contenteditable="true"> element, the :focus will incorrectly remain on the outer <div>.
Summary: :focus of nested contenteditable is incorrect → :focus of nested contenteditable is incorrect when set via arrow keys
Summary: :focus of nested contenteditable is incorrect when set via arrow keys → :focus of nested contenteditable is incorrect when navigating via arrow keys
Component: Untriaged → Editor
Product: Firefox → Core
looks like it's the issue that arrow key doesn't change the focus, based on current cursor position.
I don't get onfocus event neither with it.

tab key can change the focus.
Summary: :focus of nested contenteditable is incorrect when navigating via arrow keys → Cursor move with arrow keys doesn't change the focus of nested contenteditable
Whiteboard: [parity-chrome]
Priority: -- → P3
Edge doesn't move focus too.

If we move focus from outer contenteditable to inner contenteditable, we need to support moving focus from inner one to outer one with arrow keys.  However, I'm not sure this is reasonable behavior for our implementation.

And I wonder, it provides different UX for users in following case:

<label>name: <br><input type="text"></label>
<label>email address: <br><input type="text"></label>

vs.

<div contenteditable>
  <div contenteditable="false">
    <label>name: <br><span contenteditable></span></label>
    <label>email address: <br><span contenteditable></span></label>
  </div>
</div>

In above case, user can not move focus by arrow keys, but in bottom case, they can do it.
FYI: Even on Chrome, user cannot move focus between different editing hosts, e.g.,
> data:text/html,<div contenteditable>aaa</div><div contenteditable>bbb</div>
Somebody cced by this post might have some ideas.
Mass bug change to replace various 'parity' whiteboard flags with the new canonical keywords. (See bug 1443764 comment 13.)
Keywords: parity-chrome
Whiteboard: [parity-chrome]
Whiteboard: [h2review-noted]

I have attached a case that causes issues in Firefox:

If you click into the first editable paragraph, and then use the arrow keys to move up and down, it works as expected, although the inner contenteditable does to receive proper focus. If you however click into the inner contenteditable, it receives proper focus, but you can no longer use your arrow keys to move in/out of the editable. This case works fine in Chrome.

Severity: normal → S3
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: