Skip to content

Commit

Permalink
fix(taginput): solve defineModel macro array constrains (#942)
Browse files Browse the repository at this point in the history
  • Loading branch information
mlmoravek authored Jun 5, 2024
1 parent 4de3bd7 commit 404c5f6
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions packages/oruga/src/components/taginput/Taginput.vue
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import {
nextTick,
ref,
useAttrs,
watch,
watchEffect,
type ComponentInstance,
type PropType,
Expand Down Expand Up @@ -282,7 +281,7 @@ const emits = defineEmits<{
const autocompleteRef = ref<ComponentInstance<typeof OAutocomplete<T>>>();
const items = defineModel<T[]>({ default: [] });
const items = defineModel<T[]>({ default: () => [] });
// use form input functionalities
const { setFocus, onFocus, onBlur, onInvalid } = useInputHandler(
Expand Down Expand Up @@ -350,7 +349,7 @@ function addItem(item?: T | string): void {
? items.value.indexOf(itemToAdd) === -1
: true;
if (add && props.beforeAdding(item)) {
items.value.push(itemToAdd);
items.value = [...items.value, itemToAdd];
emits("add", itemToAdd);
}
}
Expand All @@ -363,7 +362,8 @@ function addItem(item?: T | string): void {
}
function removeItem(index: number, event?: Event): void {
const item = items.value.splice(index, 1)[0];
const item = items.value.at(index);
items.value = items.value.toSpliced(index, 1);
emits("remove", item);
if (event) event.stopPropagation();
if (props.openOnFocus && autocompleteRef.value) setFocus();
Expand Down

0 comments on commit 404c5f6

Please sign in to comment.