Skip to content

Commit

Permalink
Add setTimeout back
Browse files Browse the repository at this point in the history
  • Loading branch information
blambillotte committed Oct 18, 2024
1 parent 9680550 commit e72d01c
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/components/ScrollShadows.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,12 @@ export function ScrollShadows(props: ScrollShadowsProps) {
const onResize = useCallback(() => scrollRef.current && updateScrollProps(scrollRef.current), []);
useResizeObserver({ ref: scrollRef, onResize });

// Hack for sizing more complicated components that might not be fully drawn on initial render (such as a GridTable)
useEffect(() => void onResize());
// Hack for sizing more complicated components that might not be fully drawn on initial paint (such as a GridTable)
useEffect(() => {
// This setTimeout (without a delay) allows the current execution thread to complete (DOM is painted with the latest render)
// by placing the callback into the async event queue to ensure the fully rendered DOM is used for the resize calculations.
setTimeout(() => onResize(), 0);
}, [onResize]);

return (
<div
Expand Down

0 comments on commit e72d01c

Please sign in to comment.