Skip to content

Commit 59bb84d

Browse files
[6.x] Combobox: Fix search input focus (#12471)
Co-authored-by: Jason Varga <jason@pixelfear.com>
1 parent b464428 commit 59bb84d

1 file changed

Lines changed: 6 additions & 6 deletions

File tree

packages/ui/src/Combobox.vue

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -232,7 +232,7 @@ function pushTaggableOption(e) {
232232
}
233233
}
234234
235-
function openOnSpace(e) {
235+
function openDropdown(e) {
236236
if (dropdownOpen.value) return;
237237
if (typeof e.preventDefault === 'function') e.preventDefault();
238238
@@ -265,7 +265,7 @@ defineExpose({
265265
v-bind="attrs"
266266
>
267267
<ComboboxAnchor :class="[$attrs.class]" data-ui-combobox-anchor>
268-
<ComboboxTrigger as="div" ref="trigger" :class="triggerClasses" @keydown.space="openOnSpace" data-ui-combobox-trigger>
268+
<ComboboxTrigger as="div" ref="trigger" :class="triggerClasses" @keydown.enter="openDropdown" @keydown.space="openDropdown" data-ui-combobox-trigger>
269269
<div class="flex-1 min-w-0">
270270
<ComboboxInput
271271
v-if="searchable && (dropdownOpen || !modelValue || (multiple && placeholder))"
@@ -279,15 +279,15 @@ defineExpose({
279279
@paste.prevent="onPaste"
280280
@keydown.enter.prevent="pushTaggableOption"
281281
@blur="pushTaggableOption"
282-
@keydown.space="openOnSpace"
282+
@keydown.space="openDropdown"
283283
/>
284284
285-
<button type="button" class="w-full text-start truncate flex items-center gap-2 bg-transparent cursor-pointer focus:outline-none" v-else-if="!searchable && (dropdownOpen || !modelValue)" @keydown.space="openOnSpace" data-ui-combobox-placeholder>
285+
<button type="button" class="w-full text-start truncate flex items-center gap-2 bg-transparent cursor-pointer focus:outline-none" v-else-if="!searchable && (dropdownOpen || !modelValue)" @keydown.space="openDropdown" data-ui-combobox-placeholder>
286286
<Icon v-if="icon" :name="icon" class="text-gray-400 dark:text-white dark:opacity-50" />
287287
<span class="text-gray-400 dark:text-gray-500" v-text="placeholder" />
288288
</button>
289289
290-
<button type="button" v-else class="w-full text-start bg-transparent truncate flex items-center gap-2 cursor-pointer focus:outline-none" @keydown.space="openOnSpace" data-ui-combobox-selected-option>
290+
<button type="button" v-else class="w-full text-start bg-transparent truncate flex items-center gap-2 cursor-pointer focus:outline-none" @keydown.space="openDropdown" data-ui-combobox-selected-option>
291291
<slot name="selected-option" v-bind="{ option: selectedOption }">
292292
<Icon v-if="icon" :name="icon" class="text-white/85 dark:text-white dark:opacity-50" />
293293
<span v-if="labelHtml" v-html="getOptionLabel(selectedOption)" />
@@ -316,7 +316,7 @@ defineExpose({
316316
data-ui-combobox-content
317317
>
318318
<FocusScope
319-
trapped
319+
:trapped="!searchable"
320320
@mount-auto-focus.prevent
321321
@unmount-auto-focus="(event) => {
322322
if (event.defaultPrevented) return;

0 commit comments

Comments
 (0)