Needs review
Project:
CKEditor Accordion
Version:
2.3.0
Component:
Code
Priority:
Normal
Category:
Bug report
Assigned:
Unassigned
Reporter:
Created:
23 Jan 2026 at 19:00 UTC
Updated:
25 Jan 2026 at 22:47 UTC
Jump to comment: Most recent
JavaScript error occurs when a node body contains both an embedded media entity and a CKEditor accordion, and the module setting “Collapse all tabs by default” is unchecked:
Uncaught TypeError: Cannot read properties of null (reading 'classList')
at Object.attach (accordion.frontend.min.js)
The error happens during node edit, when interacting with the embedded media.
The issue is reproducible on Drupal core 10.6.2 as well as Drupal 11.
When the media edit dialog opens, a JavaScript error appears in the browser console
Current code:
// The first one is the correct one.
if (!drupalSettings.ckeditorAccordion.accordionStyle.collapseAll) {
$accordion.querySelector('dt:first-child').classList.add('active');
let dd = $accordion.querySelector('dd:first-of-type');
dd.classList.add('active');
dd.style.display = 'block';
}Proposed fix:
// The first one is the correct one.
if (!drupalSettings.ckeditorAccordion.accordionStyle.collapseAll) {
const firstDt = $accordion.querySelector('dt:first-child');
const firstDd = $accordion.querySelector('dd:first-of-type');
if (firstDt && firstDd) {
firstDt.classList.add('active');
firstDd.classList.add('active');
firstDd.style.display = 'block';
}
}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
Comment #3
nickolajAdds null-check for `dt:first-child` and `dd:first-of-type` elements before accessing their properties, preventing "Cannot read properties of null" TypeError.