Skip to content

Commit 1bb6a2b

Browse files
committed
fix(Popper): prevent flash of incorrectly positioned popper on open
Use requestAnimationFrame to ensure Popper.js has calculated and applied position transforms before transitioning opacity to 1. Signed-off-by: Mohamed Fall <ps.hackmaster@gmail.com>
1 parent c758eaa commit 1bb6a2b

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

packages/react-core/src/helpers/Popper/Popper.tsx

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -483,8 +483,14 @@ export const Popper: React.FunctionComponent<PopperProps> = ({
483483
clearTimeouts([transitionTimerRef, hideTimerRef]);
484484
showTimerRef.current = setTimeout(() => {
485485
setInternalIsVisible(true);
486-
setOpacity(1);
487-
onShown();
486+
// Ensures React has committed the DOM changes and the popper element is rendered
487+
requestAnimationFrame(() => {
488+
// Ensures Popper.js has calculated and applied the position transform before making element visible
489+
requestAnimationFrame(() => {
490+
setOpacity(1);
491+
onShown();
492+
});
493+
});
488494
}, entryDelay);
489495
};
490496

0 commit comments

Comments
 (0)