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({
65
65
} > ) : JSX . Element | null {
66
66
const resizeObserverManager = ElementObserverManager . getInstance ( )
67
67
const [ inView , setInView ] = useState ( initialShow ?? false )
68
+ const [ waitForInitialLoad , setWaitForInitialLoad ] = useState ( true )
68
69
const [ isShowingChildren , setIsShowingChildren ] = useState ( inView )
69
70
70
71
const [ measurements , setMeasurements ] = useState < IElementMeasurements | null > ( null )
@@ -199,6 +200,26 @@ export function VirtualElement({
199
200
} , [ ref , inView ] )
200
201
201
202
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
+
202
223
let idleCallback : number | undefined
203
224
let optimizeTimeout : number | undefined
204
225
You can’t perform that action at this time.
0 commit comments