Skip to content

Commit eac7b77

Browse files
dylanjeffersclaude
andauthored
Fix TabBar accent animation initialization in useTabs hook (#14072)
## Summary Updated the TabBar accent animation initialization to use the `from` property instead of `to` with `immediate: true` in the useSpring hook configuration. ## Key Changes - Changed `useSpring` initial animation configuration from `to: { top: 0, left: 0, width: 0 }` with `immediate: true` to `from: { top: 0, left: 0, width: 0 }` - This ensures the accent bar starts from the correct initial state (0, 0, 0) before animating to the active tab position ## Implementation Details The `from` property in react-spring defines the starting point of an animation, which is more semantically correct than using `to` with `immediate: true`. This change improves the animation lifecycle by properly establishing the initial state before any animated transitions occur, resulting in more predictable and correct accent bar positioning behavior. https://claude.ai/code/session_017YQMNfGhGb5tU4e5v9iW9o --------- Co-authored-by: Claude <noreply@anthropic.com>
1 parent a750794 commit eac7b77

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

packages/web/src/hooks/useTabs/useTabs.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -134,8 +134,7 @@ const TabBar = memo(
134134

135135
// @ts-ignore
136136
const [{ top, left, width }, setAccentProps] = useSpring(() => ({
137-
to: { top: 0, left: 0, width: 0 },
138-
immediate: true,
137+
from: { top: 0, left: 0, width: 0 },
139138
config: {
140139
mass: 1,
141140
tension: 300,
@@ -193,6 +192,7 @@ const TabBar = memo(
193192
}
194193

195194
const immediate = !getDidPositionTab()
195+
// @ts-ignore - react-spring types don't infer `to` on setter when initializer uses `from`
196196
setAccentProps({ to: accentTransforms, immediate })
197197
setDidPositionTab(true)
198198
}, [

0 commit comments

Comments
 (0)