Skip to content

Commit 6c8981c

Browse files
committed
fix(ui): fix dropdown z-index and search layout stability on focus (#2191, #2112, #1881)
1 parent 7f2fc1a commit 6c8981c

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

app/components/AppHeader.vue

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,7 @@ const route = useRoute()
151151
const isMobile = useIsMobile()
152152
const isSearchExpandedManually = shallowRef(false)
153153
const searchBoxRef = useTemplateRef('searchBoxRef')
154+
const searchContainerRef = useTemplateRef('searchContainerRef')
154155
155156
// On search page, always show search expanded on mobile
156157
const isOnHomePage = computed(() => route.name === 'index')
@@ -188,6 +189,12 @@ function handleSearchBlur() {
188189
}
189190
}
190191
192+
onClickOutside(searchContainerRef, () => {
193+
if (isMobile.value && !isOnSearchPage.value) {
194+
isSearchExpandedManually.value = false
195+
}
196+
})
197+
191198
function handleSearchFocus() {
192199
showFullSearch.value = true
193200
}
@@ -215,7 +222,7 @@ onKeyStroke(
215222
<div class="absolute inset-0 bg-bg/80 backdrop-blur-md" />
216223
<nav
217224
:aria-label="$t('nav.main_navigation')"
218-
class="relative container min-h-14 flex items-center gap-2 z-1 justify-end"
225+
class="relative container min-h-14 flex items-center gap-2 justify-end"
219226
>
220227
<!-- Mobile: Logo (navigates home) -->
221228
<NuxtLink
@@ -260,6 +267,7 @@ onKeyStroke(
260267

261268
<!-- Center: Search bar + nav items -->
262269
<div
270+
ref="searchContainerRef"
263271
class="flex-1 flex items-center md:gap-6"
264272
:class="{
265273
'hidden sm:flex': !isSearchExpanded,
@@ -277,7 +285,7 @@ onKeyStroke(
277285
/>
278286
<ul
279287
v-if="!isSearchExpanded && isConnected && npmUser"
280-
:class="{ hidden: showFullSearch }"
288+
:class="{ 'invisible pointer-events-none': showFullSearch }"
281289
class="hidden sm:flex items-center gap-4 sm:gap-6 list-none m-0 p-0"
282290
>
283291
<!-- Packages dropdown (when connected) -->

0 commit comments

Comments
 (0)