Dropdown menu IDs shouldn't be based on content

Created on 18 October 2023, about 1 year ago
Updated 1 November 2023, about 1 year ago

Problem/Motivation

Currently, when setting up the triggers for dropdown menus we create aria-controls and id attribute values based on the text in the menu item. This can be problematic depending on characters used and also doesn't guarantee a unique ID. Since Drupal assigns IDs to all menu links, we could leverage that by adding `$link_attributes['data-plugin-id'][] = $item['original_link']->getPluginId();` to the prepare_menu_items() loop and then in the javascript changing `const id = $(this).text().toLowerCase().replace(/\s/g, '');` to simply `const id = $(this).attr('data-plugin-id');`

As a side note, the panel ID is misspelled in the JS. It's `pannel` and should be `panel`.

πŸ› Bug report
Status

Fixed

Version

5.0

Component

Code

Created by

πŸ‡ΊπŸ‡ΈUnited States jnettik Denver, CO

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

Comments & Activities

Production build 0.71.5 2024