Skip to content

Fix keyboard access for sidebar toggle#3078

Open
lawrence3699 wants to merge 1 commit intorust-lang:masterfrom
lawrence3699:fix/sidebar-toggle-keyboard
Open

Fix keyboard access for sidebar toggle#3078
lawrence3699 wants to merge 1 commit intorust-lang:masterfrom
lawrence3699:fix/sidebar-toggle-keyboard

Conversation

@lawrence3699
Copy link
Copy Markdown

Fixes #2615.

The sidebar toggle was rendered as a label for the hidden checkbox. Unlike the neighboring theme and search controls, it could not receive focus as a button, and pressing Enter did not toggle the sidebar.

This keeps the checkbox/label path for no-JavaScript output, but renders the JavaScript-enabled control as a native button. The button toggles the same checkbox and dispatches its existing change handler, so the current sidebar state, ARIA updates, and localStorage behavior stay on the existing path.

The GUI regression focuses the toggle directly because Tab traversal was not reliable in the headless test harness; it verifies the control can receive focus and that Enter toggles the sidebar closed and open.

Validation:

  • cargo test --test gui -- sidebar.goml
  • cargo test --test gui -- sidebar-nojs.goml
  • npm run lint
  • git diff --check

@rustbot rustbot added the S-waiting-on-review Status: waiting on a review label Apr 27, 2026
@ShamrockLee
Copy link
Copy Markdown

I'm going to test it this week. Thank you for making this documentation generator more accessible!

@Omnikron13
Copy link
Copy Markdown

If the fix doesn't touch the no-js version, should the toggle be un-hidden there so accessibility doesn't degrade without JS?

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

Labels

S-waiting-on-review Status: waiting on a review

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Accessibility: "Toggle Table of Content" hamburger menu is not keyboard focusable

4 participants