Closes #4343 Adds accordion expand/collapse all option#5364
Closes #4343 Adds accordion expand/collapse all option#5364joshuasosa wants to merge 25 commits intomainfrom
Conversation
Co-authored-by: Joe Parsons <471936+joeparsons@users.noreply.github.com>
|
Note:
|
bberndt-uaz
left a comment
There was a problem hiding this comment.
Here are a couple suggestions for updating the JavaScript.
Co-authored-by: Brian Berndt <74572157+bberndt-uaz@users.noreply.github.com>
Co-authored-by: Brian Berndt <74572157+bberndt-uaz@users.noreply.github.com>
Thanks for reviewing and the suggestions! They look good and mostly work. Bootstrap accordions normally have parent selectors where expanding one accordion will collapse the others under the parent. The suggestion to use a click event on buttons would work only for this specific paragraph use case where it's using an "always open" approach with no parent. I added your suggestions and changed it back to manipulating class selectors directly on accordion elements to be applicable for both parent and parentless accordions. |
|
All the functionality is working as expected. I'm a bit worried about the display, however. There will be content above the accordion block in almost all cases. So I'm wondering if there is a way to add an alignment option? Or can it float next to the content? Or maybe just be a text link 🤔 |
Thanks for pointing that out! I updated it to update the btn classes, which was missed.
Sure, what sort of alignment options should be added? 'Left' and 'Right' options? (Or should it be 'Start' and 'End'?) |
|
Thanks @joshuasosa!
I'm thinking maybe just a top/bottom alignment option? I'll help find more examples of accordions in the wild, too. |
|
Pages with accordions on them:
Many have just a heading above the accordion. Some have content between the accordion and heading. |
|
Testing on existing sites with existing accordions would be beneficial |
|
I’ve applied this PR to pull-5364-azs-cybersecurity.pantheonsite.io and am not seeing the option to add the Expand/Collapse button to existing paragraphs. |
Thanks for testing! I think I'll need to add a database update for accordion paragraphs to use the new 'Quickstart Accordion Paragraph Behavior'. |
@camikazegreen Please try doing a |
djcelaya
left a comment
There was a problem hiding this comment.
This is a nice addition and I think the more compact toggle works well right-aligned where the visual accordion "controls" are already positioned.
In my local testing, I did notice that there is a chance for a single element accordion to become out of sync with its expand/collapse state. I checked Show "Expand/Collapse All" button for both accordions included in the demo content and was looking at the second one which has just one element. If it is expanded on page load, clicking the up chevron does not update the Collapse all text to Expand all.
Likewise, if it is collapsed by default and I click the down chevron, Expand all is not updated to Collapse all (since all 1 elements are now expanded).
What browser is used for the test? I'm currently unable to replicate in Windows Chrome, Firefox and Edge. |
|
Originally I was testing on Safari. I just pulled up Firefox on my Mac and am seeing the same behavior. Screen.Recording.2026-03-23.at.2.34.02.PM.mov |
I have reduced motion on my machine which made me miss this case. Re-enabling motion let me reproduce the issue. I updated it with a different approach. Please test again. |
The issue is corrected with your recent changes. Thanks for looking into that! |
|
Tugboat has finished building the preview for this pull request! Link: Dashboard: |
|
Per 3/27/26 AZ Digital Meeting: There was a note about the previous paragraph behavior settings potentially being lost after updating with this PR. I confirmed that the bottom spacing would be lost and added a database update (assisted by copilot) to migrate the accordion bottom spacing. The bottom spacing setting for accordions is the only paragraph behavior setting that was available prior to this PR and should now be addressed by the database update. To test the database update, I performed these steps:
|
djcelaya
left a comment
There was a problem hiding this comment.
I tested the config and DB updates locally against the demo content and they worked great!
|
i tested the config and DB updates locally and they worked great! Also tested by pushing the code to anthropology and did config distro and updb and seems to work well too: https://issue4343-azs-anthropology.pantheonsite.io/undergraduate-scholarships-awards |
|
Could just be personal preference, but when testing the expand/collapse all functionality on larger accordions (like in https://issue4343-azs-anthropology.pantheonsite.io/undergraduate-scholarships-awards), triggering all panels at once feels abrupt. I wonder if we added the same transition as what we have currently when opening just one panel, it would make the motion feel smoother and less jarring |
|
I agree with Kevin's comment. Please also move the checkbox above the Additional options accordion in the editing UI. |

Description
Adds an option in accordion paragraphs to add an "Expand all/Collapse all" button above the related accordion paragraph. The button will expand or collapse all accordion elements in the accordion set when clicked, respective of the button text.
Note: Assisted by Copilot for formatter and javascript functions.
Related issues
Closes #4343
How to test
Demo: https://pr5364-vehwk09c2tmxyxtbgdbjhbkm7jzb3pzh.tugboatqa.com/pages/accordions
Types of changes
Arizona Quickstart (install profile, custom modules, custom theme)
Drupal core
Drupal contrib projects
Checklist