Problem/Motivation

The `uswds_ckeditor_integration` module incorrectly loads admin/debugging CSS (`accordion.admin.css`) on front-end pages when viewing content types that have Comments enabled with a CKEditor text format that includes the USWDS Accordion plugin. This causes red dashed borders and "USWDS Accordion" overlay text to appear on ALL elements with the `.usa-accordion` class, including the USA Banner and primary navigation, defacing production pages.

This creates an unprofessional appearance on production sites, with debugging visual aids visible to end users.

Steps to reproduce

1. Install and enable `uswds_ckeditor_integration` module
2. Enable USWDS Accordion plugin in a CKEditor5 text format (e.g., `basic_html`)
3. Configure a content type (e.g., Article) to:
- Allow comments
- Use the text format with USWDS Accordion enabled for the comment field
4. Create content of that content type (does NOT need to have accordion components in the content itself)
5. Save the content
6. View the content as an anonymous user (or in an incognito browser)
7. Scroll to the comment form at the bottom of the page
8. **Observe**: Red dashed borders appear around:
- The USA Banner (government website notice at top)
- The primary navigation menu
- Any other elements with `.usa-accordion` class
9. **Observe**: "USWDS Accordion" text overlay appears at top-left of affected elements

**Key insight**: The issue is triggered by the **comment form's CKEditor instance**, not by embedded accordion content in the article body. Any page with a CKEditor instance using a text format that has the USWDS Accordion plugin enabled will trigger this bug.

**Root cause**:
- The `uswds_accordion` library (lines 2-9 of libraries.yml) incorrectly includes `css/accordion.admin.css`
- CKEditor5 loads a plugin's `library` when viewing content with embedded components
- This causes admin debugging CSS to load on front-end pages
- The CSS uses low-specificity selectors (`.usa-accordion`) that affect site-wide USWDS components

Proposed resolution

Remove `accordion.admin.css` from the main `uswds_accordion` library in `uswds_ckeditor_integration.libraries.yml`.

The admin CSS should only be in the `uswds_accordion.admin` library, which is correctly loaded only when editing content, not when viewing it.

Remaining tasks

n/a

User interface changes

n/a

API changes

n/a

Data model changes

none

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

oivanov created an issue. See original summary.

oivanov’s picture

please see the patch attached

oivanov’s picture

The merge request is ready for review

smustgrave’s picture

I appreciate the report! I’ll check it out this week

smustgrave’s picture

Status: Needs review » Needs work

This needs more work.

1. I can't replicate on the frontend seeing the admin css load
2. The css on the edit form is now missing

smustgrave’s picture

In theory admin_library should load in the editor and then the MR would be fine.

The CSS needs to load in the ckeditor so maybe the selectors need to be more specific to not bleed out.

oivanov’s picture

StatusFileSize
new670.26 KB

"2. The css on the edit form is now missing" - just to make sure I understand what you mean - after I implement the fix by commenting out the lines in question, the USWDS Accordion is fully functional in the CKEditor on both Edit mode of content nodes, and in the Comments add/edit form - see accordion_all_fine_with_fix.jpg file attached.

Something else is not working? We can have a call and look at the code if you want

smustgrave’s picture

StatusFileSize
new28.13 KB

missing

But this is gone.

oivanov’s picture

Status: Needs work » Needs review

Got it! now I understand the issue better.

how about now? the new fix is ready for review

smustgrave’s picture

Status: Needs review » Fixed

Works for me.

Now that this issue is closed, review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, credit people who helped resolve this issue.

  • smustgrave committed e2900aa1 on 3.2.x
    feat: #3556038 Admin CSS loaded on front-end for accordion components...

  • smustgrave committed 58250153 on 3.1.x
    feat: #3556038 Admin CSS loaded on front-end for accordion components...

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.