fix(menu): resolve aborted animations as false rather than reject

fixes #5638

PiperOrigin-RevId: 642044142
This commit is contained in:
Elliott Marquez 2024-06-10 15:35:00 -07:00 committed by Copybara-Service
parent 549efe057d
commit 4f7ff4f63a

View File

@ -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;
}
@ -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', () => {