sagalbot / vue-select

Everything you wish the HTML <select> element could do, wrapped up into a lightweight, extensible Vue component.
https://vue-select.org
MIT License
4.65k stars 1.34k forks source link

Bug: Entered search data persists in vue-select with 'required' and 'multiple' enabled #1832

Open ay232 opened 6 months ago

ay232 commented 6 months ago

Describe the bug When using vue-select with both required and multiple properties enabled, the search data entered in the select dropdown persists after closing the dropdown. This allows the form to be submitted even if no options are selected, as long as there is some search input remaining.

Reproduction Link CodePen You have to change simple v-select to multiple by this code: <v-select :options="books" multiple label="title"></v-select>

Steps To Reproduce

  1. Include a vue-select component in the form with properties multiple=true and required=true.
  2. Open the dropdown and type something into the search box to filter options.
  3. Close the dropdown without selecting any options.
  4. Observe that the entered search data persists in the vue-select input field.
  5. Attempt to submit the form. The form submits despite no options being chosen.

Expected behavior The expected behavior is that upon closing the dropdown, any unselected search data should be cleared, especially when no options are selected. The form should only submit when at least one option is selected, respecting the required constraint.

Screenshots Attached are screenshots demonstrating the behavior (please add your screenshots here).

Additional context This behavior can lead to confusion and potential data integrity issues, as the form believes input is present when actually no options have been selected.

Screenshots image