@@ -191,12 +191,20 @@ function computeActiveIndex(): { index: number; isSubpage: boolean } {
191191}
192192
193193function 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
202210function 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