Closed Bug 1506787 Opened 5 years ago Closed 5 years ago

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


(Core :: XUL, enhancement)

Not set



Tracking Status
firefox65 --- fixed


(Reporter: Jamie, Assigned: Jamie)



(Keywords: access)


(1 file, 1 obsolete file)

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).
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
Blocks: 1506504
After review comments and discussion, I'm switching to tabindex="-1" instead, which is more standard/future proof. Try run:
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.
Pushed by
Support tabindex attribute (including value -1) on non-control XUL elements. r=smaug
Closed: 5 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla65
Depends on: 1525569
Depends on: 1525937
You need to log in before you can comment on or make changes to this bug.