Closed Bug 1500273 Opened 6 years ago Closed 5 years ago

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

Categories

(Core :: DOM: Core & HTML, defect, P3)

defect

Tracking

()

RESOLVED FIXED
mozilla66
Tracking Status
firefox64 --- wontfix
firefox65 --- fixed
firefox66 --- fixed

People

(Reporter: timdream, Assigned: edgar)

References

(Blocks 1 open bug)

Details

Attachments

(3 files)

Attached 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.
Attached 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
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: 5 years 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.

Attachment

General

Created:
Updated:
Size: