Skip to content

Commit 2b81a88

Browse files
committed
fix document focus scroll
1 parent c3fd5ea commit 2b81a88

1 file changed

Lines changed: 9 additions & 1 deletion

File tree

frontend/app/tab/vtabbar.tsx

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,15 @@ export function VTabBar({ workspace, className }: VTabBarProps) {
144144
}
145145
const el = scrollContainerRef.current.querySelector(`[data-tabid="${activeTabId}"]`);
146146
el?.scrollIntoView({ block: "nearest" });
147-
}, [activeTabId, documentHasFocus]);
147+
}, [activeTabId]);
148+
149+
useEffect(() => {
150+
if (!documentHasFocus || activeTabId == null || scrollContainerRef.current == null) {
151+
return;
152+
}
153+
const el = scrollContainerRef.current.querySelector(`[data-tabid="${activeTabId}"]`);
154+
el?.scrollIntoView({ block: "nearest" });
155+
}, [documentHasFocus]);
148156

149157
const stopScrollLoop = useCallback(() => {
150158
if (scrollAnimFrameRef.current != null) {

0 commit comments

Comments
 (0)