Skip to content

sidebar: use native <details> for collapsible groups #3804

@olets

Description

@olets

Is your feature request related to a problem? Please describe.

Native <details> elements toggle on click, Enter, and Space.

The Vitepress sidebar collapsible groups toggle on click and Enter but not on Space.

The current behavior will register as "broken" for some users familiar with the native elements' keyboard behavior (✋).

Describe the solution you'd like

Switching the custom setup to native <details> would give them the standard behavior now. It would also reduce the required custom JS, improving maintainability and letting the Vitepress sidebar track any future updates to the native behavior for free.

Describe alternatives you've considered

Modifying the existing implementation to add toggling on Space would close the most obvious divergence from the native.

To me, that is a band-aid. This is an opportunity for improving accessibility. Switching to <details> would improve accessibility (better keyboard behavior, better announcing). Adding a spacebar listener to the existing setup would not.

Additional context

No response

Validations

Metadata

Metadata

Assignees

No one assigned

    Labels

    themeRelated to the theme

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions