Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 15 additions & 7 deletions src/frontend/src/widgets/dataTables/hooks/useContainerSize.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,13 +58,21 @@ export const useContainerSize = () => {

resizeObserver.observe(containerRef.current);

// Synchronous initial measurement to avoid first render with height=0.
// Without this, the deferred requestAnimationFrame in the ResizeObserver callback
// causes DataEditor to render with height=undefined, showing only headers.
const { width: initWidth, height: initHeight } = containerRef.current.getBoundingClientRect();
if ((initWidth > 0 || initHeight > 0) && !hasAppliedInitialRef.current) {
apply(initWidth, initHeight);
}
// Retry initial measurement until layout settles (max ~100ms).
// In nested flex layouts (e.g. HeaderLayout → Vertical → DataTable), the container
// may still have height=0 at mount time. Retrying across animation frames ensures
// we catch the moment the layout resolves.
let retries = 0;
const tryInit = () => {
if (hasAppliedInitialRef.current || !containerRef.current) return;
const { width, height } = containerRef.current.getBoundingClientRect();
if (width > 0 || height > 0) {
apply(width, height);
} else if (retries++ < 5) {
requestAnimationFrame(tryInit);
}
};
tryInit();

requestAnimationFrame(observeScrollArea);

Expand Down
Loading