multiselect
multiselect copied to clipboard
Add an option to strictly respect the external value
Currently, if you use :modelValue
without @update:modelValue
actually changing the external value of Multiselect
, upon selecting an option in the dropdown, Multiselect
value will be changed because of internal values. This may be desired behavior sometimes, but sometimes not.
For example, let's say that some request is made upon changing the value (on @update:modelValue
event), if the request fails, external value won't change, but Multiselect
will internally change the value creating an inconsistency between the states.
Maybe an option like strictlyExternal
or similar should be added?
Also, when external value is set to something that is not present in the options, the value is not respected and won't be shown as selected. To me, external value should always be respected;
Anyway, when building input components I find the pattern in vueuse/usevmodel to be the best. Notice the passive
option. Similarly the multiselect component should be able to work in both modes:
- statefull - with
ref
for internalValue, that might be updated on whatever interaction - stateless - internalValue is just a
computed
based on external value. Interactions only trigger emits in attempt to update the internalValue, but changes apply only after externalValue is updated ( viav-model
for example )