Choices-js / Choices

A vanilla JS customisable select box/text input plugin ⚡️
https://choices-js.github.io/Choices/
MIT License
6.16k stars 607 forks source link

Choices does not behave like other HTML elements in a disabled fieldset #1132

Closed tagliala closed 1 month ago

tagliala commented 1 year ago

Describe the bug It is expected that HTML elements are disabled in a globally disabled fieldset

Ref: https://developer.mozilla.org/en-US/docs/Web/HTML/Element/fieldset#attributes

If this Boolean attribute is set, all form controls that are descendants of the <fieldset>, are disabled, meaning they are not editable and won't be submitted along with the <form>. They won't receive any browsing events, like mouse clicks or focus-related events. By default browsers display such controls grayed out. Note that form elements inside the <legend> element won't be disabled.

To Reproduce Steps to reproduce the behavior:

  1. Go to https://jsfiddle.net/tagliala/yetk9sgh/13/

Expected behavior Choices.js appears and behave like a disabled fieldset

Screenshots

image

Desktop (please complete the following information):

Additional context On Firefox, the element is not interactable but it looks like an interactable field

Workaround

  callbackOnInit: function () {
    // Workaround for Choices-js/Choices#1132
    if (this.passedElement.element.closest('fieldset:disabled')) {
      this.disable()
    }
  },
Xon commented 1 month ago

Implemented as part of #1166