Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove tabindex ruleset #28425

Closed
danielnixon opened this issue Mar 7, 2019 · 5 comments
Closed

Remove tabindex ruleset #28425

danielnixon opened this issue Mar 7, 2019 · 5 comments
Assignees

Comments

@danielnixon
Copy link
Contributor

The following isn't specific to any browser or OS.

Bootstrap contains the following SCSS in _reboot.scss:

// Suppress the focus outline on elements that cannot be accessed via keyboard.
// This prevents an unwanted focus outline from appearing around elements that
// might still respond to pointer events.
//
// Credit: https://github.com/suitcss/base
[tabindex="-1"]:focus {
  outline: 0 !important;
}

This was actually removed from suitcss/base five months ago:

tabindex=-1 CSS ruleset has been removed in order to support visual feedback on programmatically focused elements.

Please consider also removing it from Bootstrap.

The visual focus indicator is required for accessibility. See e.g.:

If an author programmatically sets focus to a div (e.g. when a search form returns results you might move focus to the results) then they will need to undo Bootstrap's outline: 0.

@XhmikosR
Copy link
Member

XhmikosR commented Mar 8, 2019

/CC @patrickhlauke

@patrickhlauke
Copy link
Member

i agree in principle - though would caution that because of the naive way many browsers still apply the focus outline as a result of mouse interaction as well in these cases will have some odd repercussions. if we remove that rule from our reboot styles, we should reintroduce it specifically for some things such as modal dialogs - otherwise, even after a mouse activation, our dialogs will have a very prominent focus outline (since they're tabindex="-1" and programmatically focused).

in future, we can probably generalise this with :focus-visible, but for now we need to weigh up both the aesthetics and visual presentation for non-keyboard users and clarity for keyboard users.

@patrickhlauke
Copy link
Member

and for reference, once :focus-visible is supported, the rule could be modified to

[tabindex="-1"]:focus:not(:focus-visible) { outline: 0 !important; }

(can be verified in Chrome > 67 with experimental web features flag enabled)

@patrickhlauke
Copy link
Member

in fact, we can do both: replace the current [tabindex="-1"] reboot rule with that, and explicitly suppress outline on the modal dialog when it receives programmatic focus. once :focus-visible has more support, we can then drop the second part of this (or make it explicitly a positive :focus-visible style for modal dialogs when reached as a result of keyboard interaction)

@patrickhlauke patrickhlauke self-assigned this Mar 9, 2019
@patrickhlauke
Copy link
Member

patrickhlauke commented Mar 9, 2019

looking at our code now, it seems there's already explicit outline suppression for .modal ... so pushing the above change to reboot would not affect modals. going to investigate if there are other cases where vanilla bootstrap components currently get programmatic focus on elements with negative tabindex...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants