-
Notifications
You must be signed in to change notification settings - Fork 12
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
New Feature: Accordion - expanded state control #82
Comments
Hey @ncoetzer thanks for opening this issue. A few questions, or rather, discussion points: As a user, when clicking to expand an accordion item, the accordion should ...
As an editor, when enabling the toggle "Expand by default" on an item, the accordion should ...
The multiple vs singular items mentioned in the User and Editor criteria definitely relate. Oftentimes I'm on the fence with either only allowing a single accordion item to remain opened–but this can often force the collapse of other accordion items the user may still want opened. Overall, I like your approach! References: |
Thanks, @devinle really appreciate your feedback on this.
The current behaviour of the accordion component is to keep all other expanded items open. I'm also with you on the fence here. The behaviour of only allowing a single accordion open at a time feels kind of forced. Perhaps this could be an additional option or setting e.g. "Tabbed" or "Multi-select", which would further allow the user to select the type of accordion they would want. However, this would interfere with the toggle approach, since more than one item could be expanded on load.
With my approach, the toggle for each individual item only becomes available and effective if the global option is disabled. The purpose of the global option is a quick way to force the behaviour on all items, regardless of their individual setting. Both the global and individual item options are by default set to Screen.Recording.2021-08-19.at.10.08.42.AM.1.mp4 |
We'll preferably introduce this new feature to the component here (CSS + JS) and the block library (InspectorControls) in tandem. This will ensure the new settings are also available to administrators in the admin. |
Is your feature request related to a problem? Please describe.
We've recently had a request from a client (Campbell's) to extend the accordion component with functionality to control its initial expanded state upon page load. By default, this feature is not built-in and would probably have to be added manually (which I'm almost sure has been done several times in the past). This seemed to be a handy feature that could benefit other projects/clients as well.
Describe the solution you'd like
As a solution, we've implemented
ToggleControls
on two levels:A global toggle that controls the expanded state for all accordion items. When the global switch is enabled, all inner child items will inherit the setting
Item-specific toggle that only controls its own expanded state. This option is only available if the global option has been disabled
As a result, not only would administrators have more control to customize the initial state of the accordion, but it would also improve the user experience in the editor at the same time.
The text was updated successfully, but these errors were encountered: