Closed Bug 2034851 Opened 22 days ago Closed 20 hours ago

Sequential focus navigation starting point should be separate from selection

Categories

(Core :: DOM: UI Events & Focus Handling, defect, P3)

defect

Tracking

()

RESOLVED FIXED
152 Branch
Tracking Status
firefox152 --- fixed

People

(Reporter: ltenenbaum, Assigned: ltenenbaum)

References

(Blocks 1 open bug)

Details

Attachments

(3 files)

Attached file testcase.html

Currently the sequential focus navigation starting point is determined by either the focused element or the selection. But it would be best to keep track of it separately, like Chrome does. Otherwise we can run into issues, such as sequential navigation resetting when the focused element becomes non-focusable (see attached test case).

Component: DOM: Core & HTML → DOM: UI Events & Focus Handling
Duplicate of this bug: 1940403
No longer duplicate of this bug: 1940403
See Also: → 2035573
Blocks: 2031575

The attached test case now works as expected because in bug 2032191 we decided to move the selection when the focused element becomes non-focusable. But other browsers don't move the selection in those cases, so this would be a better way of fixing that.

Is it? In general it seems nice that e.g. clicking or finding or selecting text also moves the sequential focus navigation starting point...

Attached file selectionchange.html

I mean, we could also just permanently use the workaround in bug 2032191. The only issue is that we are changing the selection when the focused element becomes non-focusable or is removed, which is different from other browsers (see attached). Maybe that's not such a big issue, though.

(And to be clear, clicking or selecting text still does set the sequential focus navigation starting point with this patch.)

Yeah I guess changing selection as a result of focus moving is not amazing / it's rather unexpected... That said, why is the sequential focus navigation a whole nsRange? Can't it be a plain RangeBoundary? That'd simplify a bit the setup at least. When would the range not be collapsed?

Oh you're selecting the whole node... That seems unfortunate, that triggers all sorts of funny slow paths doesn't it? Why can't it be a point, just in case it's been removed? Can't we handle that in ContentWillBeRemoved, adjusting as necessary? I guess it's not necessarily fast either...

Yes, the problem is that we want to do slightly different things depending on whether or not the node is removed. I was just using a non-collapsed range as an easy way of detecting that, but maybe using ContentWillBeRemoved or something would be better…

See Also: → 2038418
Pushed by ltenenbaum@mozilla.com: https://github.com/mozilla-firefox/firefox/commit/9e978fd6dad5 https://hg.mozilla.org/integration/autoland/rev/da409e4fc877 Separate sequential focus navigation starting point from selection. r=dom-core,smaug

Created web-platform-tests PR https://github.com/web-platform-tests/wpt/pull/59902 for changes under testing/web-platform/tests

Status: ASSIGNED → RESOLVED
Closed: 20 hours ago
Resolution: --- → FIXED
Target Milestone: --- → 152 Branch

Upstream PR merged by moz-wptsync-bot

You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: