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

Ability to disable toggling/closing details #10864

Open
jacobrask opened this issue Dec 16, 2024 · 0 comments
Open

Ability to disable toggling/closing details #10864

jacobrask opened this issue Dec 16, 2024 · 0 comments
Labels
addition/proposal New features or enhancements needs implementer interest Moving the issue forward requires implementers to express interest

Comments

@jacobrask
Copy link

jacobrask commented Dec 16, 2024

What problem are you trying to solve?

There are several use cases where you would want to disable the opening and closing of details – especially as browsers will now automatically toggle details based on for example Find in Page:

  • Tab-like interfaces with exclusive details where one is always open
  • Requiring completion of one step before continuing to the next
  • Preventing closing a currently active step with required data entry

Details

When implementing accordions, in some designs it's not appropriate to allow closing of an open details without opening another. This is especially true of "tab-like" accordions. Tabs and Accordions have similarities and are sometimes used interchangeably depending on the viewport size, and in a tabbed interface you typically can't close the active tab without opening another. The desired pattern is similar to the exclusive pattern with the name attribute on details, but should also prevent the currently expanded details from being closed. See https://www.makethingsaccessible.com/guides/responsive-and-accessible-tabbed-interfaces/ for some details.

Other examples are components where you step through a set of required steps, one expanding after the other. You may be allowed to expand the next steps, but should not be allowed to close the current step until it has been completed. In other cases you should not be able to show the next step until the current one has been completed.

The GitHub Issues reporter is a good example, where you can expand the next sections by interacting with their forms, but you cannot explicitly collapse the section you are current writing in.

What solutions exist today?

You would need to use a MutationObserver to reset the open state. You'd also have to disable keyboard and mouse events on summary and reset the accessibility role of summary.

How would you solve it?

Adding a disabled attribute to details:

<details name="accordion" disabled open></details>
<details name="accordion"></details>

would solve most of the use cases above, even if it would still require tracking of the open state in JavaScript to update the disabled state accordingly.

Anything else?

No response

@jacobrask jacobrask added addition/proposal New features or enhancements needs implementer interest Moving the issue forward requires implementers to express interest labels Dec 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
addition/proposal New features or enhancements needs implementer interest Moving the issue forward requires implementers to express interest
Development

No branches or pull requests

1 participant