Accordions / Tabs break if a section/tab title starts with a number

Created on 2 December 2024, 16 days ago

Problem/Motivation

Accordions / Tabs cannot be expanded if the user names a section/tab title beginning with a number.

Doing so causes the #id of the rendered element to start with a number, which is invalid and throws a JS error.

Steps to reproduce

Add an accordion (or Tab) to a page
Name the titles and content:
- 1 first title
-- 1 content
- 2 second title
-- 2 content

Save
View the page.

The accordion section / tab and any subsequent ones will be unexpandable.
The browser console reports:

drupal.js?v=10.3.9:64 Uncaught SyntaxError: Failed to execute 'querySelector' on 'Document': '#1-first-a284ba81' is not a valid selector.
    at accordion.js?sno5fg:18:33

Proposed resolution

IDs generated from content are sanitised.

πŸ› Bug report
Status

Active

Version

2.0

Component

Code

Created by

πŸ‡¬πŸ‡§United Kingdom andrew robinson

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

Merge Requests

Comments & Activities

Production build 0.71.5 2024