File tree Expand file tree Collapse file tree 1 file changed +21
-0
lines changed
packages/webui/src/client/lib Expand file tree Collapse file tree 1 file changed +21
-0
lines changed Original file line number Diff line number Diff line change @@ -65,6 +65,7 @@ export function VirtualElement({
6565} > ) : JSX . Element | null {
6666 const resizeObserverManager = ElementObserverManager . getInstance ( )
6767 const [ inView , setInView ] = useState ( initialShow ?? false )
68+ const [ waitForInitialLoad , setWaitForInitialLoad ] = useState ( true )
6869 const [ isShowingChildren , setIsShowingChildren ] = useState ( inView )
6970
7071 const [ measurements , setMeasurements ] = useState < IElementMeasurements | null > ( null )
@@ -199,6 +200,26 @@ export function VirtualElement({
199200 } , [ ref , inView ] )
200201
201202 useEffect ( ( ) => {
203+ if ( inView === true ) {
204+ setIsShowingChildren ( true )
205+
206+ // Schedule a measurement after a short delay
207+ if ( waitForInitialLoad && ref ) {
208+ const initialMeasurementTimeout = window . setTimeout ( ( ) => {
209+ const measurements = measureElement ( ref , placeholderHeight )
210+ if ( measurements ) {
211+ setMeasurements ( measurements )
212+ setWaitForInitialLoad ( false )
213+ }
214+ } , 800 )
215+
216+ return ( ) => {
217+ window . clearTimeout ( initialMeasurementTimeout )
218+ }
219+ }
220+ return
221+ }
222+
202223 let idleCallback : number | undefined
203224 let optimizeTimeout : number | undefined
204225
You can’t perform that action at this time.
0 commit comments