Skip to content

Restore keyboard focus indicator on bare .btn buttons - #14785

Draft
cwickham wants to merge 1 commit into
mainfrom
bare-btn-focus-indicator
Draft

Restore keyboard focus indicator on bare .btn buttons#14785
cwickham wants to merge 1 commit into
mainfrom
bare-btn-focus-indicator

Conversation

@cwickham

Copy link
Copy Markdown
Member

Description

Closes #14774.

Three Quarto buttons carry Bootstrap's btn class with no btn-* variant class: the code tools button, a website's sidebar toggle, and a website's sidebar search button. Bootstrap's .btn:focus-visible rule sets outline: 0 plus a box-shadow that only the variant classes define. On these buttons the box-shadow computes to none, 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:

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.ts covers 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 computed outline-style is not none. 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 standalone code-tools document and a minimal website with a collapsed sidebar.

Checklist

I have (if applicable):

  • referenced the GitHub issue this PR closes
  • updated the appropriate changelog in the PR
  • ensured the present test suite passes (new and neighboring Playwright specs pass locally; will check once CI passes)
  • added new tests
  • created a separate documentation PR in Quarto's website repo and linked it to this PR — not needed, see above
AI-assisted PR
  • AI tool used: Claude Code
  • Codebase grounding: local clone of quarto-cli
  • Human review: I have reviewed, tested, and verified the AI-generated content before submitting.

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).
@posit-snyk-bot

posit-snyk-bot commented Aug 18, 2026

Copy link
Copy Markdown
Collaborator

Snyk checks have passed. No issues have been found so far.

Status Scan Engine Critical High Medium Low Total (0)
Open Source Security 0 0 0 0 0 issues
Licenses 0 0 0 0 0 issues

💻 Catch issues earlier using the plugins for VS Code, JetBrains IDEs, Visual Studio, and Eclipse.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

a11y: buttons with no Bootstrap variant class have no visible keyboard focus indicator

2 participants