Skip to content

Commit

Permalink
fix: #181 MultiSelect can now be cleared manually.
Browse files Browse the repository at this point in the history
  • Loading branch information
tankerkiller125 committed Oct 4, 2024
1 parent ab48f55 commit 8656610
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions frontend/components/Form/Multiselect.vue
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,14 @@
<span v-for="itm in value" :key="name != '' ? itm[name] : itm" class="badge">
{{ name != "" ? itm[name] : itm }}
</span>
<button
v-if="value.length > 0"
type="button"
class="absolute inset-y-0 right-6 flex items-center rounded-r-md px-2 focus:outline-none"
@click="clear"
>
<MdiClose class="size-5" />
</button>
</div>
<div
tabindex="0"
Expand Down Expand Up @@ -36,6 +44,8 @@
</template>

<script lang="ts" setup>
import MdiClose from "~icons/mdi/close";
const emit = defineEmits(["update:modelValue"]);
const props = defineProps({
label: {
Expand Down Expand Up @@ -78,6 +88,10 @@
});
});
function clear() {
value.value = [];
}
const selected = computed<string[]>(() => {
return value.value.map(itm => itm[props.uniqueField]);
});
Expand Down

0 comments on commit 8656610

Please sign in to comment.