@bagelink/vue 1.7.49 → 1.7.51

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@bagelink/vue",
3
3
  "type": "module",
4
- "version": "1.7.49",
4
+ "version": "1.7.51",
5
5
  "description": "Bagel core sdk packages",
6
6
  "author": {
7
7
  "name": "Bagel Studio",
@@ -179,10 +179,15 @@ watch(
179
179
  () => props.modelValue,
180
180
  (newVal: Option | Option[]) => {
181
181
  if (!props.multiselect) {
182
- const newOption = Array.isArray(props.options)
183
- ? (props.options.find(o => getValue(o) === newVal) ?? newVal)
184
- : newVal
185
- if (newOption != null && !isSelected(newOption)) { selectedItems.value = [newOption] }
182
+ if (newVal == null) {
183
+ // Clear selection when value is undefined/null
184
+ if (selectedItems.value.length > 0) { selectedItems.value = [] }
185
+ } else {
186
+ const newOption = Array.isArray(props.options)
187
+ ? (props.options.find(o => getValue(o) === newVal) ?? newVal)
188
+ : newVal
189
+ if (!isSelected(newOption)) { selectedItems.value = [newOption] }
190
+ }
186
191
  } else {
187
192
  const newData = [newVal].flat()
188
193
  const isSame = compareArrays(newData, selectedItems.value)
@@ -245,7 +250,8 @@ watch(
245
250
 
246
251
  onMounted(() => {
247
252
  const opts = props.options
248
- if (props.defaultValue !== undefined && Array.isArray(opts)) {
253
+ // Only apply defaultValue if modelValue is not set
254
+ if (props.modelValue == null && props.defaultValue !== undefined && Array.isArray(opts)) {
249
255
  const defaultOption = opts.find(
250
256
  (o: Option) => getValue(o) === getValue(props.defaultValue),
251
257
  )