Restore keyboard focus indicator on bare .btn buttons - #14785
Draft
cwickham wants to merge 1 commit into
Draft
Conversation
The code tools button, website sidebar toggle, and website sidebar search button carry Bootstrap's btn class with no btn-* variant class. Bootstrap's .btn:focus-visible sets outline: 0 and substitutes a box-shadow that only the variant classes define, so these buttons took keyboard focus with no visible indicator, failing WCAG 2.4.7. Restore the browser's native focus ring on them with outline: revert. An outline also survives forced-colors mode, where box-shadow computes to none, and matches the code copy button's indicator (#12118).
Collaborator
✅ Snyk checks have passed. No issues have been found so far.
💻 Catch issues earlier using the plugins for VS Code, JetBrains IDEs, Visual Studio, and Eclipse. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Closes #14774.
Three Quarto buttons carry Bootstrap's
btnclass with nobtn-*variant class: the code tools button, a website's sidebar toggle, and a website's sidebar search button. Bootstrap's.btn:focus-visiblerule setsoutline: 0plus a box-shadow that only the variant classes define. On these buttons the box-shadow computes tonone, so keyboard focus shows no indicator. This fails WCAG 2.2 SC 2.4.7 (Focus Visible).This PR adds one rule that restores the browser's native focus ring on the three buttons with
outline: revert.Reasons to prefer the native ring over Bootstrap's box-shadow halo:
none.outline(Withforced-colors: active, focus-rings may be invisible twbs/bootstrap#42062), so the fix does not depend on a mechanism that upstream is retiring.revertsupport (Safari before 15.4) drop the declaration, and behavior is unchanged from today.Site authors can still restyle the focus state, because user SCSS compiles after Quarto's rules. For the code tools button the new selector has the same specificity as Bootstrap's, so any override that worked before still works (verified in a rendered document). For the two nav buttons an override must match the new selector's specificity, for example by including
.quarto-secondary-nav.No documentation change is needed: the fix adds no option and changes no documented behavior.
Tests
The new spec
html-focus-indicator-bare-btn.spec.tscovers all three buttons in Chromium, Firefox, and WebKit. It moves focus with real Tab presses (Option+Tab on WebKit, which ships Safari's default keyboard-navigation settings), then asserts that the computedoutline-styleis notnone. Real key presses are necessary because programmatic focus does not match:focus-visible. All nine tests fail on a build without the fix and pass with it. The fixtures are a standalonecode-toolsdocument and a minimal website with a collapsed sidebar.Checklist
I have (if applicable):
AI-assisted PR