Skip to content

Commit 9a83db2

Browse files
IsQuyetIMB11
andauthored
fix: ensure NavTabs slider aligns correctly with dynamic tabs (#5377)
* fix(ui): ensure NavTabs slider aligns correctly with dynamic tabs * fix: lint --------- Co-authored-by: Calum H. (IMB11) <contact@cal.engineer>
1 parent 30c4871 commit 9a83db2

File tree

1 file changed

+15
-6
lines changed

1 file changed

+15
-6
lines changed

apps/frontend/src/components/ui/NavTabs.vue

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -191,12 +191,20 @@ function computeActiveIndex(): { index: number; isSubpage: boolean } {
191191
}
192192
193193
function getTabElement(index: number): HTMLElement | null {
194-
if (!tabLinkElements.value?.[index]) return null
194+
if (index === -1) return null
195195
196-
// In navigation mode, elements are NuxtLinks with $el property
197-
// In local mode, elements are plain divs
198-
const element = tabLinkElements.value[index]
199-
return props.mode === 'navigation' ? (element as any).$el : element
196+
const container = scrollContainer.value as HTMLElement | undefined
197+
if (!container) return null
198+
199+
const tabs = container.querySelectorAll('.button-animation')
200+
const element = tabs[index] as HTMLElement | undefined
201+
202+
if (!element) return null
203+
204+
// In navigation mode, elements are NuxtLinks, but since we used querySelectorAll,
205+
// we already have the raw HTMLElement ($el), so no further conversion is needed.
206+
// In local mode, elements are already plain divs.
207+
return element
200208
}
201209
202210
function positionSlider() {
@@ -253,7 +261,8 @@ function animateSliderTo(newPosition: {
253261
sliderBottom.value = newPosition.bottom
254262
}
255263
256-
function updateActiveTab() {
264+
async function updateActiveTab() {
265+
await nextTick()
257266
const { index, isSubpage } = computeActiveIndex()
258267
currentActiveIndex.value = index
259268
subpageSelected.value = isSubpage

0 commit comments

Comments
 (0)