Skip to content

Commit 40be2fa

Browse files
committed
fix(ResizablePanel): drift in controllable state * 2
1 parent 74df17f commit 40be2fa

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

src/components/layout/ResizablePanel.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -301,7 +301,7 @@ function ResizablePanel(
301301
},
302302
});
303303

304-
// Since we sync provided size and the local one in two ways
304+
// Since we sync provided size and the local one in two ways,
305305
// we need a way to prevent infinite loop in some cases.
306306
// We will run this in setTimeout and make sure it will get the most recent state.
307307
const notifyChange = useEvent(() => {
@@ -329,7 +329,7 @@ function ResizablePanel(
329329
}, [visualSize, isDragging]);
330330

331331
useEffect(() => {
332-
setTimeout(notifyChange, 120);
332+
requestIdleCallback(notifyChange);
333333
}, [providedSize]);
334334

335335
const mods = useMemo(() => {
@@ -355,9 +355,9 @@ function ResizablePanel(
355355
}
356356
{...mergeProps(restProps, {
357357
style: {
358-
// We set a current size further via width/min-width/max-width styles to respect size boundaries
358+
// We set the current size further via width/min-width/max-width styles to respect size boundaries
359359
'--size': `${size}px`,
360-
// We use a separate visual size to paint the handler for smoother experience
360+
// We use a separate visual size to paint the handler for a smoother experience
361361
'--visual-size': `${visualSize}px`,
362362
'--min-size': typeof minSize === 'number' ? `${minSize}px` : minSize,
363363
'--max-size': typeof maxSize === 'number' ? `${maxSize}px` : maxSize,

0 commit comments

Comments
 (0)