Disabled chosen widget UI glitch

Created on 12 August 2024, 5 months ago
Updated 3 September 2024, 4 months ago

Problem/Motivation

The dropdown is visible and items are selectable when the input element is disabled. Form validation filters out the selected values but they are visible on the UI before submitting the form. Only 4.x is affected because older versions use a different library where it is properly implemented: https://github.com/harvesthq/chosen

Steps to reproduce

Add a field to a content type and use the chosen widget. Disable the field in a form alter hook:
$form['your_field']['#disabled'] = TRUE;

Proposed resolution

The bug is coming from the library jjj/chosen, I reported the issue and created a PR in the repository of the library:
https://github.com/JJJ/chosen/issues/56
https://github.com/JJJ/chosen/pull/57

Note that the PR https://github.com/JJJ/chosen/pull/57 is against the master branch. Because the project is automatically built by grunt and this contrib module uses the tag 2.2.1 I had to create a patch file using the same changes from the 2.2.1 tag. The uploaded patch file in this issue can be used for drupal/chosen.

🐛 Bug report
Status

Needs review

Version

4.0

Component

Code

Created by

🇭🇺Hungary peter_serfozo

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

Comments & Activities

Production build 0.71.5 2024