Provide a way to make non-control XUL elements focusable but not tabbable

RESOLVED FIXED in Firefox 65

Status

()

enhancement
RESOLVED FIXED
7 months ago
5 months ago

People

(Reporter: Jamie, Assigned: Jamie)

Tracking

({access})

unspecified
mozilla65
Points:
---
Dependency tree / graph

Firefox Tracking Flags

(firefox65 fixed)

Details

Attachments

(1 attachment, 1 obsolete attachment)

Assignee

Description

7 months ago
Bug 1436086 will make browser toolbars navigable with the keyboard. Rather than every button being in the tab order (which would be pretty inefficient for users), groups of buttons will occupy a single tab stop, with left/right arrows being used to navigate within the group. This means that toolbar buttons need to be focusable but not in the tab order. (This includes <toolbarbutton>, but also other elements like <image> and <box> which are used as button-like things on toolbars.)

It's possible to achieve this by temporarily setting -moz-user-focus to normal, calling element.focus(), then setting -moz-user-focus back to ignore. However, this is a pretty big hack and causes some weirdness for accessibility (and maybe other things). Also, this means that tests can't simply call element.focus() on toolbar buttons; they too must use this -moz-user-focus setting hack.

I propose we add a new -moz-user-focus: no-tab value. We could alternatively allow tabindex="-1" like HTML, but this would mean changing the markup for every single button on the toolbar, which is likely to result in a lot of churn (and broken keyboard access in future).
Assignee

Comment 1

7 months ago
This is similar to tabindex="-1", but non-control XUL elements don't support that.
It will primarily be useful for buttons on toolbars, which will be grouped under a single tab stop for efficiency.
Attachment #9024662 - Attachment is obsolete: true
Assignee

Updated

7 months ago
Blocks: 1506504
Assignee

Comment 4

7 months ago
After review comments and discussion, I'm switching to tabindex="-1" instead, which is more standard/future proof. Try run:
https://treeherder.mozilla.org/#/jobs?repo=try&revision=d8e0a570e0cc55401c2782e9208e5e3a716ebf91
Assignee

Comment 5

7 months ago
Previously, the tabindex attribute wasn't supported on non-control XUL elements at all.
The only way to make those focusable was to use -moz-user-focus: normal.
However, that caused the element to be included in the tab order; there was no way to make it focusable but not tabbable.
This can now be achieved using tabindex="-1".
This will primarily be useful for buttons on toolbars, which will be grouped under a single tab stop for efficiency.

For consistency, this also changes the behaviour of tabindex="-1" with -moz-user-focus: ignore on XUL controls.
Previously, -moz-user-focus: ignore would override tabindex="-1", making the element unfocusable.
Now, the tabindex attribute always overrides if explicitly specified.

Comment 8

7 months ago
Pushed by jteh@mozilla.com:
https://hg.mozilla.org/integration/autoland/rev/38844846c6ae
Support tabindex attribute (including value -1) on non-control XUL elements. r=smaug

Comment 9

7 months ago
bugherder
https://hg.mozilla.org/mozilla-central/rev/38844846c6ae
Status: NEW → RESOLVED
Closed: 7 months ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla65
Depends on: 1525569
Assignee

Updated

5 months ago
Depends on: 1525937
You need to log in before you can comment on or make changes to this bug.