Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
53 changes: 38 additions & 15 deletions packages/ui/src/components/base/Combobox.vue
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,25 @@
@clear="handleSearchClear"
>
<template v-if="showChevron" #trailing>
<ChevronLeftIcon
class="cursor-pointer size-5 text-secondary transition-transform duration-150"
:class="isOpen ? (openDirection === 'down' ? 'rotate-90' : '-rotate-90') : '-rotate-90'"
<button
type="button"
tabindex="-1"
class="flex size-7 -m-2 shrink-0 cursor-pointer items-center justify-center border-none bg-transparent p-0 text-secondary disabled:cursor-not-allowed"
:disabled="disabled"
:aria-expanded="isOpen"
:aria-haspopup="listbox ? 'listbox' : 'menu'"
aria-label="Toggle dropdown"
@mousedown.prevent
@click.stop="handleSearchIconClick"
/>
@click.stop="handleSearchChevronClick"
>
<ChevronLeftIcon
class="pointer-events-none size-5 transition-transform duration-150"
:class="
isOpen ? (openDirection === 'down' ? 'rotate-90' : '-rotate-90') : '-rotate-90'
"
aria-hidden="true"
/>
</button>
</template>
</Input>
</div>
Expand Down Expand Up @@ -1024,13 +1037,16 @@ function handleSearchClick() {
}
}

function handleSearchIconClick() {
if (isOpen.value) {
closeDropdown(false)
return
}
function handleSearchChevronClick() {
if (props.disabled) return

openDropdown()
const wasOpen = isOpen.value
searchTriggerRef.value?.focus()
if (wasOpen) {
closeDropdown()
} else {
openDropdown()
}
}

function handleWindowResize() {
Expand Down Expand Up @@ -1062,10 +1078,17 @@ function startPositionTracking() {
listenerWindow.addEventListener('beforeunload', handleWindowClose)
listenerWindow.visualViewport?.addEventListener('scroll', handleViewportChange)
listenerWindow.visualViewport?.addEventListener('resize', handleViewportChange)
stopOutsideClick = onClickOutside(dropdownRef, () => closeDropdown(false), {
window: listenerWindow,
ignore: outsideClickIgnoreTargets,
})
stopOutsideClick = onClickOutside(
dropdownRef,
(event) => {
if (containerRef.value && event.composedPath().includes(containerRef.value)) return
closeDropdown(false)
},
{
window: listenerWindow,
ignore: outsideClickIgnoreTargets,
},
)
}

function stopPositionTracking() {
Expand Down
Loading