diff --git a/packages/core/src/tabs/tabs-indicator.tsx b/packages/core/src/tabs/tabs-indicator.tsx index 65d2702f..f7fc7145 100644 --- a/packages/core/src/tabs/tabs-indicator.tsx +++ b/packages/core/src/tabs/tabs-indicator.tsx @@ -115,7 +115,28 @@ export function TabsIndicator( ), ); - createResizeObserver(context.selectedTab, computeStyle); + const [resizing, setResizing] = createSignal(false); + + let timeout: NodeJS.Timeout | null = null; + let prevTarget: any = null; + createResizeObserver(context.selectedTab, (_, t) => { + if (prevTarget !== t) { + prevTarget = t; + return; + } + + setResizing(true); + + if (timeout) clearTimeout(timeout); + + // gives the browser a chance to skip any animations that are disabled while resizing + timeout = setTimeout(() => { + timeout = null; + setResizing(false); + }, 1); + + computeStyle(); + }); return ( @@ -123,6 +144,7 @@ export function TabsIndicator( role="presentation" style={combineStyle(style(), local.style)} data-orientation={context.orientation()} + data-resizing={resizing()} {...others} /> );