fix(AnalyticalTable): prevent empty table body flash on first render#8375
Merged
fix(AnalyticalTable): prevent empty table body flash on first render#8375
Conversation
Use useLayoutEffect instead of useEffect for the isMounted state in VirtualTableBodyContainer to eliminate a one-frame flash where table headers render without any body rows.
Lukas742
requested changes
Mar 24, 2026
Contributor
Lukas742
left a comment
There was a problem hiding this comment.
Hi @abzokhattab
Thanks for the contribution! The PR looks good to me, I only have a small remark regarding consistency. (See below)
packages/main/src/components/AnalyticalTable/TableBody/VirtualTableBodyContainer.tsx
Outdated
Show resolved
Hide resolved
packages/main/src/components/AnalyticalTable/TableBody/VirtualTableBodyContainer.tsx
Outdated
Show resolved
Hide resolved
packages/main/src/components/AnalyticalTable/TableBody/VirtualTableBodyContainer.tsx
Outdated
Show resolved
Hide resolved
Pull Request Test Coverage Report for Build 23461917284Warning: This coverage report may be inaccurate.This pull request's base commit is no longer the HEAD commit of its target branch. This means it includes changes from outside the original pull request, including, potentially, unrelated coverage changes.
Details
💛 - Coveralls |
Use useIsomorphicLayoutEffect instead of useEffect when toggling isMounted in VirtualTableBodyContainer so rows render before the first paint.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
When an
AnalyticalTablewithvisibleRowCountMode="Auto"mounts, there is a brief but visible flash where the table headers and toolbar are fully rendered while the body area is empty. After a frame the rows appear, but the flicker is noticeable — especially in applications where the table is rendered inside a layout that itself triggers re-layouts on mount (e.g. anObjectPagewithIconTabBarmode).Root cause
VirtualTableBodyContainerneeds the body<div>to be in the DOM before the virtualizer can measure it and render rows. To enforce this, it gates the row children behind anisMountedflag:The problem is the choice of
useEffect. React'suseEffectruns after the browser paints, which means every mount follows this sequence:<div ref={parentRef}>is in the document, butisMountedis stillfalse, sochildren(the rows) are not part of the tree.useEffectfire, findingparentRef.currentset and callingsetIsMounted(true).Step 2 is the flash. It is a single frame, but it is consistently reproducible on every mount.
Fix
Replace
useEffectwithuseLayoutEffect. BecauseuseLayoutEffectruns synchronously after DOM mutations but before the browser paints, the ref check and state update happen in time for React to include the rows in the very first paint. The user never sees an empty body.Why this is safe
parentRef.currentis guaranteed to be available when the layout effect runs — the<div ref={parentRef}>renders unconditionally in the same component's JSX, so the ref is assigned during the commit phase before any effects fire.AnalyticalTableitself already usesuseIsomorphicLayoutEffect(which resolves touseLayoutEffecton the client) in its mainindex.tsxfor similar DOM-measurement work, so this is consistent with the existing codebase.useEffect: "If your Effect is doing something visual (for example, positioning a tooltip), and the delay is noticeable (for example, it flickers), replaceuseEffectwithuseLayoutEffect."Result
Before — empty body flashes for one frame on every mount:
Screen.Recording.2026-03-23.at.23.01.01.mov
After — rows appear together with headers, no flash:
Screen.Recording.2026-03-23.at.22.56.02.mov