Fix LazyMotion animation not firing when state changes before features load#3501
Fix LazyMotion animation not firing when state changes before features load#3501mattgperry merged 2 commits intomainfrom
Conversation
…s load When using LazyMotion with async feature loading, state changes that occur before features load (~5ms after mount) would cause the element to snap to its final value instead of animating. This happened because the VisualElement wasn't created until features loaded, so there was no AnimationState to track the state changes. The fix tracks whether the component has already been through React's commit phase before the VisualElement is created. If so, we set manuallyAnimateOnMount to true, which forces the initial animation to run rather than being blocked. Fixes #2759 Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Code ReviewSummaryThis PR fixes a race condition bug where animations would snap to their final value instead of animating when state changes occur before LazyMotion features finish loading asynchronously. The fix is clean, minimal, and well-tested. ✅ Strengths
🔍 Minor Observations
🎯 Code Quality
🔒 Security & Performance
📝 Suggestions (Optional Enhancements)
✅ VerdictApprove with minor suggestions. This is a well-crafted fix that solves a real user pain point (issue #2759) with minimal code changes. The test coverage is strong, and the implementation leverages existing patterns correctly. The optional suggestions above would enhance robustness but are not blockers. Great work! 🚀 Review generated via Claude Code |
Summary
manuallyAnimateOnMount = trueto force animationFixes #2759
Test plan
lazy-motion-fast-state.tsverifies animation completes correctlylazy-motion-fast-state.tsxdemonstrates the fix🤖 Generated with Claude Code