Skip to content

Commit

Permalink
fix(menu): resolve aborted animations as false rather than reject
Browse files Browse the repository at this point in the history
fixes #5638

PiperOrigin-RevId: 642044142
  • Loading branch information
Elliott Marquez authored and copybara-github committed Jun 10, 2024
1 parent 549efe0 commit 4f7ff4f
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions menu/internal/menu.ts
Original file line number Diff line number Diff line change
Expand Up @@ -770,20 +770,18 @@ export abstract class Menu extends LitElement {
*/
private animateClose() {
let resolve!: (value: unknown) => void;
let reject!: () => void;

// This promise blocks the surface position controller from setting
// display: none on the surface which will interfere with this animation.
const animationEnded = new Promise((res, rej) => {
const animationEnded = new Promise((res) => {
resolve = res;
reject = rej;
});

const surfaceEl = this.surfaceEl;
const slotEl = this.slotEl;

if (!surfaceEl || !slotEl) {
reject();
resolve(false);
return animationEnded;
}

Expand Down Expand Up @@ -870,7 +868,7 @@ export abstract class Menu extends LitElement {
animation.cancel();
child.classList.toggle('md-menu-hidden', false);
});
reject();
resolve(false);
});

surfaceHeightAnimation.addEventListener('finish', () => {
Expand Down

0 comments on commit 4f7ff4f

Please sign in to comment.