Choices icon indicating copy to clipboard operation
Choices copied to clipboard

Required attribute not working on select field

Open otatechie opened this issue 3 years ago • 3 comments

Describe the bug The required attribute is a boolean attribute. When present, it specifies the user is required to select a value before submitting the form.

Expected behavior If present on any of these input types and elements, the :required pseudo class will match.

Desktop (please complete the following information):

  • OS: [e.g. iOS]
  • Browser [e.g. Brave]
  • Version [e.g. 1.35.100]

Additional context Required helps provide an indication to users informing them the form control is required. The aria-required attribute indicates that user input is required on the element before a form may be submitted improving accessibility.

otatechie avatar Feb 11 '22 14:02 otatechie

Please provide a simplified code example demonstrating the bug.

mtriff avatar Feb 12 '22 19:02 mtriff

<select class="js-choice">
    <option value="">Please select </option>
    <option value="Red">Red </option>
    <option value="Yellow">Yellow </option>
</select>

<script>
    const choices = new Choices('.js-choice');
</script>

otatechie avatar Feb 12 '22 19:02 otatechie

@thehappytechie There appears to be CSS only fix mentioned in #449.

.choices[data-type*="select-one"] select.choices__input {
  display: block !important;
  opacity: 0;
  pointer-events: none;
  position: absolute;
  left: 0;
  bottom: 0;
}

amineo avatar Jun 22 '22 19:06 amineo