Skip to content

Commit d821ec5

Browse files
committed
refactor(multiselect): selected values are shown in input
1 parent 6745124 commit d821ec5

1 file changed

Lines changed: 29 additions & 29 deletions

File tree

frontend/src/components/Controls/MultiSelect.vue

Lines changed: 29 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -6,19 +6,34 @@
66
</label>
77
<Combobox v-model="selectedValue" nullable v-slot="{ open }">
88
<div class="relative w-full">
9-
<ComboboxInput
10-
ref="search"
11-
class="form-input w-full focus-visible:!ring-0"
12-
type="text"
13-
:displayValue="() => query"
14-
@change="
15-
(e) => {
16-
query = e.target.value
17-
}
18-
"
19-
autocomplete="off"
20-
@focus="onFocus"
21-
/>
9+
<div
10+
class="flex flex-wrap items-center gap-1.5 w-full rounded-lg border border-outline-gray-2 bg-surface-gray-2 px-2 py-1.5 cursor-text transition-colors focus-within:border-outline-gray-4 focus-within:bg-surface-white focus-within:shadow-sm"
11+
@click="focusInput"
12+
>
13+
<button
14+
v-for="value in values"
15+
:key="value"
16+
type="button"
17+
class="inline-flex items-center gap-1 bg-surface-white border border-outline-gray-2 text-ink-gray-7 pl-2 pr-1.5 py-0.5 rounded text-base leading-5"
18+
@click.stop="removeValue(value)"
19+
>
20+
<span>{{ value }}</span>
21+
<X class="size-3.5 stroke-1.5 shrink-0" />
22+
</button>
23+
<ComboboxInput
24+
ref="search"
25+
class="flex-1 min-w-[4rem] border-none outline-none bg-transparent p-0 text-base focus:ring-0"
26+
type="text"
27+
:placeholder="!values?.length ? __('Search...') : ''"
28+
@change="
29+
(e) => {
30+
query = e.target.value
31+
}
32+
"
33+
autocomplete="off"
34+
@focus="onFocus"
35+
/>
36+
</div>
2237
<ComboboxButton ref="trigger" class="hidden" />
2338
<ComboboxOptions
2439
v-show="open"
@@ -27,7 +42,7 @@
2742
>
2843
<div
2944
class="flex-1 my-1 overflow-y-auto px-1.5"
30-
:class="options.length ? 'min-h-[6rem]' : 'min-h-[3.8rem]'"
45+
:class="options.length ? 'min-h-[6rem]' : 'min-h-[1rem]'"
3146
>
3247
<template v-if="options.length">
3348
<ComboboxOption
@@ -81,21 +96,6 @@
8196
</ComboboxOptions>
8297
</div>
8398
</Combobox>
84-
85-
<!-- Selected values -->
86-
<div v-if="values?.length" class="grid grid-cols-2 gap-2 mt-1">
87-
<div
88-
v-for="value in values"
89-
:key="value"
90-
class="flex items-center justify-between break-all bg-surface-gray-2 text-ink-gray-7 p-2 rounded-md"
91-
>
92-
<span>{{ value }}</span>
93-
<X
94-
class="size-4 stroke-1.5 cursor-pointer"
95-
@click="removeValue(value)"
96-
/>
97-
</div>
98-
</div>
9999
</div>
100100
</template>
101101

0 commit comments

Comments
 (0)