Skip to content

fix: prevent detail flash on close with fill forwards and rAF cancel#11419

Merged
web-padawan merged 1 commit into
mainfrom
fix/animation-fill-forwards
Mar 28, 2026
Merged

fix: prevent detail flash on close with fill forwards and rAF cancel#11419
web-padawan merged 1 commit into
mainfrom
fix/animation-fill-forwards

Conversation

@web-padawan
Copy link
Copy Markdown
Member

@web-padawan web-padawan commented Mar 27, 2026

Summary

Two fixes to eliminate a one-frame flash when closing the detail panel:

  • fill: 'forwards' on Web Animations — keeps the final keyframe applied after the animation finishes, preventing the CSS resting state (translate: none from has-detail) from showing between animation end and the finished Promise resolution. The fill effect is cleaned up when __endTransition cancels the animation, which happens after the callback has already cleared has-detail.

  • cancelAnimationFrame(this.__resizeRaf) in __endTransition — during the closing animation, ResizeObserver can fire and capture stale layout state (hasDetail: true) into a deferred requestAnimationFrame. When the animation finishes, the callback correctly clears has-detail, but the stale rAF would re-apply it on the next frame. Cancelling it in __endTransition prevents the stale state from overwriting the correct post-transition state.

Both fixes are needed: fill: 'forwards' bridges the synchronous gap between animation end and Promise resolution, while the rAF cancel prevents the asynchronous ResizeObserver race.

Test plan

  • yarn test --group master-detail-layout — all tests pass
  • Manual: rapidly open/close overlay detail, verify no backdrop/detail flash on close

🤖 Generated with Claude Code

Two fixes to eliminate a one-frame flash when closing the detail:

1. Add fill: 'forwards' to Web Animations — keeps the final keyframe
   applied after the animation finishes, preventing the CSS resting
   state (translate: none from has-detail) from showing between
   animation end and the finished Promise resolution. Cleaned up
   when __endTransition cancels the animation, after the callback
   has already cleared has-detail.

2. Cancel pending ResizeObserver rAF in __endTransition — during the
   closing animation, ResizeObserver can capture stale layout state
   (hasDetail: true) into a deferred rAF that would re-apply
   has-detail on the next frame.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@web-padawan web-padawan force-pushed the fix/animation-fill-forwards branch from c33004a to 3e85e58 Compare March 27, 2026 14:45
@sonarqubecloud
Copy link
Copy Markdown

@web-padawan web-padawan changed the title fix: cancel stale ResizeObserver rAF in MDL __endTransition fix: prevent detail flash on close with fill forwards and rAF cancel Mar 27, 2026
@web-padawan web-padawan requested a review from vursen March 27, 2026 14:51
@web-padawan web-padawan merged commit a2e3604 into main Mar 28, 2026
10 checks passed
@web-padawan web-padawan deleted the fix/animation-fill-forwards branch March 28, 2026 07:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants