Fix DropdownInput differentiating num/string keys

This commit is contained in:
adro 2023-10-31 22:39:44 +01:00
parent 64206134ab
commit 76e6eb5af8

View file

@ -127,7 +127,7 @@ function focusIn() {
function toggle(key: any) { function toggle(key: any) {
if (multiple) { if (multiple) {
const mv = modelValue as Index[]; const mv = modelValue as Index[];
if (mv?.includes(key)) mv?.splice(mv?.indexOf(key), 1); if (mv?.some((x: Index) => x == key)) mv?.splice(mv?.indexOf(key), 1);
else mv?.push(key); else mv?.push(key);
return; return;
} }
@ -205,10 +205,10 @@ function handleKeydown(e: KeyboardEvent) {
<Transition name="fade-fast"> <Transition name="fade-fast">
<div tabindex="-1" class="dropdown" v-if="expanded"> <div tabindex="-1" class="dropdown" v-if="expanded">
<div v-for="([key, option], index) in Object.entries(options)" :key="key" <div v-for="([key, option], index) in Object.entries(options)" :key="key"
:class="{selected: multiple ? modelValue?.includes(key) : key == modelValue, navigated: navigated === index + 1}" :class="{selected: multiple ? modelValue?.some((x: Index) => x == key) : key == modelValue, navigated: navigated === index + 1}"
@click="() => toggle(key)"> @click="() => toggle(key)">
<template v-if="multiple"> <template v-if="multiple">
<i-material-symbols-check-box-outline v-if="modelValue?.includes(key)" width="1em" height="1em"/> <i-material-symbols-check-box-outline v-if="modelValue?.some((x: Index) => x == key)" width="1em" height="1em"/>
<i-material-symbols-check-box-outline-blank v-else width="1em" height="1em"/> <i-material-symbols-check-box-outline-blank v-else width="1em" height="1em"/>
</template> </template>
<div v-text="option.display"/> <div v-text="option.display"/>