- Issue created by @yassermussa
- πΊπΎUruguay yassermussa
Proposed Solution
I have created a patch that:
- Updates Chosen version from 1.1.0 to 1.8.7 (more recent and stable)
- Implements a polyfill for
$.trim()
when it's not available - Delays Chosen initialization to ensure the polyfill is available
- Moves initialization to a separate JavaScript file for better maintenance
The patch modifies three files:
- Creates a new file
js/tb-megamenu-chosen-fix.js
with the polyfill and delayed initialization - Modifies
js/tb-megamenu.backend.js
to remove the original initialization - Updates
tb_megamenu.libraries.yml
to include the new file and update Chosen version
Benefits
- Maintains compatibility with Drupal 11 and jQuery 4.x
- Doesn't break compatibility with previous versions
- Uses a more recent and secure version of Chosen
- Implements an elegant solution with a polyfill instead of modifying the library
Patch
https://www.drupal.org/files/issues/2025-06-15/tb_megamenu-jquery4-fix-3... β