Accordions outside of text fields get affected by JS

Created on 9 September 2024, 2 months ago
Updated 13 September 2024, 2 months ago

Problem/Motivation

The JS in uswds_accordion.js has a couple of jQuery selectors that match all USWDS accordions on the page, even if they were not created by this module. This JS is changing their "id" and "aria-controls" attributes, which is resulting in JS errors when the USWDS tries to run its code.

Steps to reproduce

Have a USWDS accordion baked on the page, such as in a template file. Then add an accordion in Ckeditor and save the page. You should see a JS error.

Proposed resolution

For our purposes we have patched this module to add ".text-formatted" to the jQuery selectors, to ensure that this module only targets accordions that were created in Ckeditor. I'm not 100% this "text-formatted" class is always there though (maybe it is just our theme).

Remaining tasks

I'm interested in feedback. I'm happy to post our patch if that would help.

πŸ› Bug report
Status

Active

Version

3.0

Component

Code

Created by

πŸ‡ΊπŸ‡ΈUnited States brockfanning

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Production build 0.71.5 2024