Shift-Tab does not take the focus back to input inside Shadow DOM

RESOLVED FIXED in Firefox 65

Status

()

defect
P3
normal
RESOLVED FIXED
10 months ago
5 months ago

People

(Reporter: timdream, Assigned: edgar)

Tracking

(Blocks 1 bug)

Trunk
mozilla66
Points:
---
Dependency tree / graph
Bug Flags:
in-testsuite +

Firefox Tracking Flags

(firefox64 wontfix, firefox65 fixed, firefox66 fixed)

Details

Attachments

(3 attachments)

Posted file sd-focus.html
STR:

See test case, which creates a DOM like

<body>
  <input> #1
  <span tabIndex="0"> #2
    shadowRoot
      <input> #3
      <input> #4
      <input> #5
  <input> #6

Expected

1. Focus on #1 and press tab will take focus from #1 to #6
2. Focus on #6 and press Shift+Tab will take focus backward from #6 to #1

Actual

1. as expected
2. focus jumps from #6 to #1

Note

This is not what I saw in https://bugzilla.mozilla.org/show_bug.cgi?id=1496242#c3 . I am not sure if they are related.
Posted file sd-focus-1.html
This one does what's expected:

<body>
  <input> #1
  <span tabIndex="0"> #2
    shadowRoot
      <span tabIndex="0"> #3
      <span tabIndex="0"> #4
      <span tabIndex="0"> #5
  <input> #6
Blocks: shadowdom
Priority: -- → P3
Assignee: nobody → echen
When entering into a Shadow DOM in backward navigation, we set currentContent to the top-level host [1] but the frame still points to the last frame in Shadow DOM which could be a non-focusable frame. So we skip Shadow DOM and also the host in this case [2]. 

[1] https://searchfox.org/mozilla-central/rev/69f9d5002c6e3c5c571a348916fb174e6a7b4acd/dom/base/nsFocusManager.cpp#3308
[2] https://searchfox.org/mozilla-central/rev/69f9d5002c6e3c5c571a348916fb174e6a7b4acd/dom/base/nsFocusManager.cpp#3387-3394
When entering into a Shadow DOM in backward navigation, the frame still points
to the last frame in Shadow DOM which could be a non-focusable frame, so move
the handling of backward navigation for Shadow DOM upward.
Pushed by echen@mozilla.com:
https://hg.mozilla.org/integration/autoland/rev/c93e450706ae
Ensure backward focus navigation works in Shadow DOM; r=smaug
https://hg.mozilla.org/mozilla-central/rev/c93e450706ae
Status: NEW → RESOLVED
Closed: 8 months ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla66
Is there a user impact here which justifies backport consideration or can this ride the trains?
Flags: needinfo?(echen)
Flags: in-testsuite+
Comment on attachment 9030241 [details]
Bug 1500273 - Ensure backward focus navigation works in Shadow DOM;

[Beta/Release Uplift Approval Request]

Feature/Bug causing the regression: Not a regression

User impact if declined: Focus backward navigation doesn't work as expected with Shadow DOM in certain cases.

Is this code covered by automated tests?: Yes

Has the fix been verified in Nightly?: Yes

Needs manual test from QE?: No

If yes, steps to reproduce: 

List of other uplifts needed: None

Risk to taking this patch: Low

Why is the change risky/not risky? (and alternatives if risky): The change isn't complicated and only affects Shadow DOM case.

String changes made/needed: None
Flags: needinfo?(echen)
Attachment #9030241 - Flags: approval-mozilla-beta?
Comment on attachment 9030241 [details]
Bug 1500273 - Ensure backward focus navigation works in Shadow DOM;

[Triage Comment]
Fixes broken focus backward navigation with Shadow DOM in certain cases. Approved for 65.0b6.
Attachment #9030241 - Flags: approval-mozilla-beta? → approval-mozilla-beta+
Component: DOM → DOM: Core & HTML
You need to log in before you can comment on or make changes to this bug.