Fix DatePicker popup flashing at top-left in Chromium

Latent bug: useEffect runs after paint, so the popup rendered at
{top:0, left:0} before repositioning. Switched to useLayoutEffect
which runs synchronously before paint, ensuring correct position
on first frame. Both Chromium and Firefox unaffected by the change.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
Kyle 2026-03-03 16:26:49 +08:00
parent 63b3a3a073
commit e20c04ac4f

View File

@ -160,7 +160,7 @@ const DatePicker = React.forwardRef<HTMLButtonElement, DatePickerProps>(
});
}, [mode, usesNativeInput]);
React.useEffect(() => {
React.useLayoutEffect(() => {
if (!open) return;
updatePosition();
window.addEventListener('scroll', updatePosition, true);