@@ -151,6 +151,11 @@ export function SessionSidePanel(props: {
151151 let changesEl : HTMLDivElement | undefined
152152 let allEl : HTMLDivElement | undefined
153153
154+ const syncFileTreeScrolled = ( el ?: HTMLDivElement ) => {
155+ const next = ( el ?. scrollTop ?? 0 ) > 0
156+ setStore ( "fileTreeScrolled" , ( current ) => ( current === next ? current : next ) )
157+ }
158+
154159 const handleDragStart = ( event : unknown ) => {
155160 const id = getDraggableId ( event )
156161 if ( ! id ) return
@@ -173,10 +178,7 @@ export function SessionSidePanel(props: {
173178
174179 createEffect ( ( ) => {
175180 if ( ! layout . fileTree . opened ( ) ) return
176- const tab = fileTreeTab ( )
177- const el = tab === "changes" ? changesEl : allEl
178- const next = ( el ?. scrollTop ?? 0 ) > 0
179- setStore ( "fileTreeScrolled" , ( current ) => ( current === next ? current : next ) )
181+ syncFileTreeScrolled ( fileTreeTab ( ) === "changes" ? changesEl : allEl )
180182 } )
181183
182184 createEffect ( ( ) => {
@@ -359,11 +361,7 @@ export function SessionSidePanel(props: {
359361 < Tabs . Content
360362 value = "changes"
361363 ref = { ( el : HTMLDivElement ) => ( changesEl = el ) }
362- onScroll = { ( e : UIEvent & { currentTarget : HTMLDivElement } ) => {
363- if ( fileTreeTab ( ) !== "changes" ) return
364- const next = e . currentTarget . scrollTop > 0
365- setStore ( "fileTreeScrolled" , ( current ) => ( current === next ? current : next ) )
366- } }
364+ onScroll = { ( e : UIEvent & { currentTarget : HTMLDivElement } ) => syncFileTreeScrolled ( e . currentTarget ) }
367365 class = "bg-background-stronger px-3 py-0"
368366 >
369367 < Switch >
@@ -397,11 +395,7 @@ export function SessionSidePanel(props: {
397395 < Tabs . Content
398396 value = "all"
399397 ref = { ( el : HTMLDivElement ) => ( allEl = el ) }
400- onScroll = { ( e : UIEvent & { currentTarget : HTMLDivElement } ) => {
401- if ( fileTreeTab ( ) !== "all" ) return
402- const next = e . currentTarget . scrollTop > 0
403- setStore ( "fileTreeScrolled" , ( current ) => ( current === next ? current : next ) )
404- } }
398+ onScroll = { ( e : UIEvent & { currentTarget : HTMLDivElement } ) => syncFileTreeScrolled ( e . currentTarget ) }
405399 class = "bg-background-stronger px-3 py-0"
406400 >
407401 < FileTree
0 commit comments