Skip to content

Commit ad744ff

Browse files
authored
fix: fix Menu briefly flashes on first open (#4876)
1 parent 8a1c86a commit ad744ff

File tree

1 file changed

+19
-17
lines changed

1 file changed

+19
-17
lines changed

src/components/Menu/Menu.tsx

Lines changed: 19 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -345,23 +345,25 @@ const Menu = ({
345345
});
346346

347347
attachListeners();
348-
const { animation } = theme;
349-
Animated.parallel([
350-
Animated.timing(scaleAnimationRef.current, {
351-
toValue: { x: menuLayoutResult.width, y: menuLayoutResult.height },
352-
duration: ANIMATION_DURATION * animation.scale,
353-
easing: EASING,
354-
useNativeDriver: true,
355-
}),
356-
Animated.timing(opacityAnimationRef.current, {
357-
toValue: 1,
358-
duration: ANIMATION_DURATION * animation.scale,
359-
easing: EASING,
360-
useNativeDriver: true,
361-
}),
362-
]).start(() => {
363-
focusFirstDOMNode(menuRef.current);
364-
prevRendered.current = true;
348+
requestAnimationFrame(() => {
349+
const { animation } = theme;
350+
Animated.parallel([
351+
Animated.timing(scaleAnimationRef.current, {
352+
toValue: { x: menuLayoutResult.width, y: menuLayoutResult.height },
353+
duration: ANIMATION_DURATION * animation.scale,
354+
easing: EASING,
355+
useNativeDriver: true,
356+
}),
357+
Animated.timing(opacityAnimationRef.current, {
358+
toValue: 1,
359+
duration: ANIMATION_DURATION * animation.scale,
360+
easing: EASING,
361+
useNativeDriver: true,
362+
}),
363+
]).start(() => {
364+
focusFirstDOMNode(menuRef.current);
365+
prevRendered.current = true;
366+
});
365367
});
366368
}, [anchor, attachListeners, measureAnchorLayout, theme]);
367369

0 commit comments

Comments
 (0)