Closed Bug 1518121 Opened 6 years ago Closed 6 years ago

Focus seems broken when `overflow` is set in native Shadow DOM

Categories

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

63 Branch
defect

Tracking

()

RESOLVED FIXED
mozilla67
Tracking Status
firefox-esr60 --- unaffected
firefox65 --- wontfix
firefox66 --- wontfix
firefox67 --- fixed

People

(Reporter: wes_ngrongsen, Assigned: edgar)

References

(Blocks 1 open bug)

Details

(Keywords: regression)

Attachments

(5 files)

User Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:66.0) Gecko/20100101 Firefox/66.0 Steps to reproduce: ## Description To better illustrate the problem, I've created a simple reduced test case at Glitch. I realized that tab order does not work as expected by when tabbing thru focusable elements in a document when there is an element with `overflow` set to either `auto` or `scroll` (or as long as there is an overflow content in between focusable elements). The tab order will not focus elements below the overflow content. I don't think this is an expected behavior because it breaks logical tab order of a document. The demo works fine on browsers with native Shadow DOM v1 supported like Chrome but not tested on Safari (tabbing does not work on Safari of my machine for some reasons). FWIW, It affects FF63 and above and not tested without Shadow DOM (if it does not work without SD, it simple means tab order is totally broken.) ## Additional info Demo URL - https://pumped-seat.glitch.me Full source code - https://glitch.com/edit/#!/pumped-seat?path=views/broken-focus.js:1:0 Actual results: Tab order looks broken. Focus will be restricted to focusable elements above overflow content. Expected results: Tab order should work as expected on browsers with native Shadow DOM v1 supported like Chrome. Focusable elements below overflow content should be focusable thru tabbing.

I verified this issue on Windows 10 x64 with the latest Firefox release version 64.0.2 (64-bit), Firefox Nightly 66.0a1 (2019-01-10) (64-bit) and I cannot reproduce it.
Can you please test this in safe mode? Here is a link that can help you: https://goo.gl/AR5o9d.
If you still have the issue please create a new profile, you have the steps here: https://support.mozilla.org/en-US/kb/profile-manager-create-and-remove-firefox-profiles?redirectlocale=en-US&redirectslug=Managing-profiles#w_starting-the-profile-manager
Also, can you please create a videoscreen capture when you can and if you have time? To be sure that we understand the same steps to reproduce this issue.

Flags: needinfo?(wes_ngrongsen)

Daniel, I've recorded a simple video to demonstrate the issue at https://youtu.be/qettFyfY3Fs.

From the video, you can see that focus never moves to the button below the overflow content as I was tabbing thru.

Flags: needinfo?(wes_ngrongsen)

Also, I was running Firefox Nightly 66 with the latest update on Windows x64 (with latest update too) in safe mode while recording. Hope this helps in the investigation.

Thanks a lot for the testcase and for the report!
Reproduced the issue on Firefox Nightly 67, Beta 66 and Release 65 on Windows 10 x64

Mozzregression also revealed that this is a regression caused by shadowDOM:

Last good revision: 1879856ca1ab0def40038be7482a9bc2e140cfee
First bad revision: 2718c0bfff1d6e9cf07e28212cf7d1dd5b09485e

Pushlog:
https://hg.mozilla.org/integration/mozilla-inbound/pushloghtml?fromchange=1879856ca1ab0def40038be7482a9bc2e140cfee&tochange=2718c0bfff1d6e9cf07e28212cf7d1dd5b09485e

Regression introduced by: Bug 1490820

Olli, can you please take a look at it? Not sure if other bug reports highlighted this regression or not.

Status: UNCONFIRMED → NEW
Has Regression Range: --- → yes
Has STR: --- → yes
Component: Untriaged → DOM
Ever confirmed: true
Flags: needinfo?(bugs)
Keywords: regression
Product: Firefox → Core

Thanks for updating this bug report. Good to hear that the bug has been verified and confirmed as a regression.

:wchen, could you look in to this given Olli's backlog?

Flags: needinfo?(william)

I flagged :wchen as the reviewer of another patch for shadow DOM that mentioned focus (bug 1079236).

wchen isn't actively around.

Flags: needinfo?(william)

Jared, can we find another owner for this bug and prioritize it with regards to our upcoming releases? Is that something we want to fix before the next ESR or can it remain in the backlog until we have cycles to fix it? Thanks

Blocks: 1490820
Flags: needinfo?(jaws)

(In reply to Pascal Chevrel:pascalc from comment #9)

Jared, can we find another owner for this bug and prioritize it with regards to our upcoming releases? Is that something we want to fix before the next ESR or can it remain in the backlog until we have cycles to fix it? Thanks

I believe Edgar is able to provide inputs here. :)

Flags: needinfo?(bugs) → needinfo?(echen)
Attached file test.html

reduced test script.

So the issue here is that nsIFrame::IsFocusable returns true with tabIndex = 0 for a scrollable frame [1], so we could move foucus on it. But in [2], we just get tabIndex from the content which returns -1 in this case, then we could not able to find next tabbable content correctly.

[1] https://searchfox.org/mozilla-central/rev/9eb30227b21e0aa40d51d9f9b08bb0b113c5fadb/layout/generic/nsFrame.cpp#9529-9530
[2] https://searchfox.org/mozilla-central/rev/9eb30227b21e0aa40d51d9f9b08bb0b113c5fadb/dom/base/nsFocusManager.cpp#3147-3151

Assignee: nobody → echen

(In reply to Pascal Chevrel:pascalc from comment #9)

Jared, can we find another owner for this bug and prioritize it with regards to our upcoming releases? Is that something we want to fix before the next ESR or can it remain in the backlog until we have cycles to fix it? Thanks

I think fixing this is not something complicated, we could try to fix this before next ESR (68).

Flags: needinfo?(echen)
Blocks: shadowdom
Flags: needinfo?(jaws)
Priority: -- → P2
Attached file Test 2.html

Found another case that Shift+Tab doesn't work as expected when 'overflow' is set on slot element.

Steps to reproduce:

  1. Click input text has blue border to move focus on it.
  2. Press Shift+Tab

Actual result:
The focus moves to input text with value=3.

Expect result:
The focus should move to input text with value=4.

This is for the scrollable frame, because nsIFrame::IsFocusable of a scrollable
frame returns true with tabIndex = 0 even if the content has no tabIndex
attribute.

The mIndexInInserted keeps pointing to the last assigned node of a slot parent
when we are at the end of child list. So when we calles GetPreviousChild when we
are at the end of child list, ExplicitChildIterator will skip last assigned node.

Pushed by echen@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/dfeedf139126 Part 1: Check isFocusable from frame first if content has frame; r=smaug https://hg.mozilla.org/integration/autoland/rev/db9ccc4f8c6e Part 2: Update ExplicitChildIterator correctly when we are at the end of child list of a slot parent; r=smaug https://hg.mozilla.org/integration/autoland/rev/8a65241e7c3d Part 3: Add tests for scrollable frame in Shadow DOM; r=smaug

Awesome! Thank you for the great work.

Is this something which should be nominated for Beta approval or can it ride the trains?

Flags: needinfo?(echen)
Flags: in-testsuite+
Flags: needinfo?(echen)
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: