Skip to content

fix(material/dialog): prevent visual jump by removing open class together with closing class - #34137

Open
abdul-karim-mia wants to merge 1 commit into
angular:mainfrom
abdul-karim-mia:fix/dialog-exit-animation-jump
Open

abdul-karim-mia wants to merge 1 commit into
angular:mainfrom
abdul-karim-mia:fix/dialog-exit-animation-jump

Conversation

@abdul-karim-mia

Copy link
Copy Markdown

When _startExitAnimation() is called, mdc-dialog--open was previously removed synchronously while mdc-dialog--closing was scheduled in a requestAnimationFrame callback.

When close() is called from within a requestAnimationFrame callback (such as during zoneless change detection scheduling or reactive effect updates), the nested rAF is deferred to the next frame. During that intermediate frame, the dialog container renders with neither class, applying the base un-opened styles (scale(0.8) / opacity: 0) and causing the dialog surface to visibly shrink and then snap back when mdc-dialog--closing is applied.

Solution

Remove mdc-dialog--open and add mdc-dialog--closing together within the requestAnimationFrame callback so the container transitions directly from the open state to the closing state without an intermediate class-less frame. When animations are disabled, mdc-dialog--open is removed immediately in the non-animated branch.

Verification

  • Ran Prettier format check: passed (clean formatting).
  • TypeScript compile / typecheck (tsc -p src/material/tsconfig.json --noEmit): clean on dialog files (0 errors).
  • Added unit test in src/material/dialog/dialog.spec.ts asserting that mdc-dialog--open is not removed prematurely before the closing animation frame executes.

Fixes #34123

…ther with closing class

When _startExitAnimation() is called, mdc-dialog--open was previously removed synchronously while mdc-dialog--closing was scheduled in a requestAnimationFrame callback. When close() is called from within a requestAnimationFrame callback (such as during zoneless change detection scheduling or effect reactions), the nested rAF is deferred to the next frame. During that intermediate frame, the dialog container renders with neither class, applying the base un-opened styles (scale(0.8) / opacity: 0) and causing the dialog surface to visibly shrink and then snap back.

Remove mdc-dialog--open and add mdc-dialog--closing together within the requestAnimationFrame callback so the container transitions directly from the open state to the closing state without an intermediate class-less frame.

Fixes angular#34123

Signed-off-by: Abdul karim mia <97598943+abdul-karim-mia@users.noreply.github.com>

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

1 participant