@@ -111,6 +111,7 @@ export function VTabBar({ workspace, className }: VTabBarProps) {
111111 const env = useWaveEnv < VTabBarEnv > ( ) ;
112112 const activeTabId = useAtomValue ( env . atoms . staticTabId ) ;
113113 const reinitVersion = useAtomValue ( env . atoms . reinitVersion ) ;
114+ const documentHasFocus = useAtomValue ( env . atoms . documentHasFocus ) ;
114115 const tabIds = workspace ?. tabids ?? [ ] ;
115116
116117 const [ orderedTabIds , setOrderedTabIds ] = useState < string [ ] > ( tabIds ) ;
@@ -122,6 +123,7 @@ export function VTabBar({ workspace, className }: VTabBarProps) {
122123 const [ isNewTabHovered , setIsNewTabHovered ] = useState ( false ) ;
123124 const dragSourceRef = useRef < string | null > ( null ) ;
124125 const didResetHoverForDragRef = useRef ( false ) ;
126+ const scrollContainerRef = useRef < HTMLDivElement > ( null ) ;
125127
126128 useEffect ( ( ) => {
127129 setOrderedTabIds ( tabIds ) ;
@@ -133,6 +135,14 @@ export function VTabBar({ workspace, className }: VTabBarProps) {
133135 }
134136 } , [ reinitVersion ] ) ;
135137
138+ useEffect ( ( ) => {
139+ if ( activeTabId == null || scrollContainerRef . current == null ) {
140+ return ;
141+ }
142+ const el = scrollContainerRef . current . querySelector ( `[data-tabid="${ activeTabId } "]` ) ;
143+ el ?. scrollIntoView ( { block : "nearest" } ) ;
144+ } , [ activeTabId , documentHasFocus ] ) ;
145+
136146 const clearDragState = ( ) => {
137147 if ( dragSourceRef . current != null && ! didResetHoverForDragRef . current ) {
138148 didResetHoverForDragRef . current = true ;
@@ -171,6 +181,7 @@ export function VTabBar({ workspace, className }: VTabBarProps) {
171181 style = { { backdropFilter : "blur(20px)" , background : "rgba(0, 0, 0, 0.35)" } }
172182 >
173183 < div
184+ ref = { scrollContainerRef }
174185 className = "relative flex min-h-0 flex-1 flex-col overflow-y-auto"
175186 onDragOver = { ( event ) => {
176187 event . preventDefault ( ) ;
@@ -249,25 +260,25 @@ export function VTabBar({ workspace, className }: VTabBarProps) {
249260 />
250261 ) ;
251262 } ) }
252- < button
253- type = "button"
254- className = "group relative flex h-9 w-full shrink-0 cursor-pointer items-center gap-1.5 pl-3 pr-3 text-xs text-secondary/60 transition-colors hover:text-primary select-none whitespace-nowrap"
255- onClick = { ( ) => env . electron . createTab ( ) }
256- onMouseEnter = { ( ) => setIsNewTabHovered ( true ) }
257- onMouseLeave = { ( ) => setIsNewTabHovered ( false ) }
258- aria-label = "New Tab"
259- >
260- < div className = "pointer-events-none absolute inset-x-1 inset-y-[4px] rounded-sm bg-transparent transition-colors group-hover:bg-hover" />
261- < i className = "fa fa-solid fa-plus" style = { { fontSize : "10px" } } />
262- < span > New Tab</ span >
263- </ button >
264263 { dragTabId != null && dropIndex != null && dropLineTop != null && (
265264 < div
266265 className = "pointer-events-none absolute left-0 right-0 border-t-2 border-accent/80"
267266 style = { { top : dropLineTop , transform : "translateY(-1px)" } }
268267 />
269268 ) }
270269 </ div >
270+ < button
271+ type = "button"
272+ className = "group relative flex h-9 w-full shrink-0 cursor-pointer items-center gap-1.5 pl-3 pr-3 text-xs text-secondary/60 transition-colors hover:text-primary select-none whitespace-nowrap"
273+ onClick = { ( ) => env . electron . createTab ( ) }
274+ onMouseEnter = { ( ) => setIsNewTabHovered ( true ) }
275+ onMouseLeave = { ( ) => setIsNewTabHovered ( false ) }
276+ aria-label = "New Tab"
277+ >
278+ < div className = "pointer-events-none absolute inset-x-1 inset-y-[4px] rounded-sm bg-transparent transition-colors group-hover:bg-hover" />
279+ < i className = "fa fa-solid fa-plus" style = { { fontSize : "10px" } } />
280+ < span > New Tab</ span >
281+ </ button >
271282 </ div >
272283 ) ;
273284}
0 commit comments