JS error due to browser cached script after updating to 5.0.1

Created on 24 March 2025, about 2 months ago

Problem/Motivation

After updating the module from 4.0.3 to 5.0.1 (and replacing the library as instructed by the readme), when visiting a form where chosen is used with a browser that has been used to visit the same form but with the previous version of chosen, the following JS error is received (and the chosen functionality is broken):

drupal.js?v=10.3.14:64 Uncaught TypeError: select.oldChosen is not a function
    at ce.chosen (chosen.js?v=1.7.0:35:22)
    at Object.createChosen (chosen.js?v=1.7.0:116:16)
    at Object.<anonymous> (chosen.js?v=1.7.0:103:14)
    ...

Steps to reproduce

Tested on Drupal Core 10.3.14
1. Starting with a project using Chosen version 4.x visit an edit form using the Chosen library for a field.
2. Update Chosen to 5.0.1 following instructions
3. Visit the form again (make sure browser cache is not turned off)
4. The JS error occurs, as the old cached version of chosen.js is used by the browser.

Proposed resolution

After modifying the version number for drupal.chosen in chosen.libraries.yml and rebuilding the cache the issue is fixed (without the need to clear the browser cache, as the version parameter is updated in the URL of the js file, the new version of the file is used by the browser).

See chosen.libraries.yml:

drupal.chosen:
  remote: https://drupal.org/project/chosen
  version: 1.7.0

Remaining tasks

Update the version of drupal.chosen library in chosen.libraries.yml. As for what version number should be used: I'm not sure, probably 0.0.4, but I'd like to hear opinion from maintainers.

User interface changes

None

API changes

None

Data model changes

None

πŸ› Bug report
Status

Active

Version

5.0

Component

Code

Created by

πŸ‡§πŸ‡ͺBelgium keszthelyi Brussels

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