Skip to content

Commit 626b4ef

Browse files
Elliott Marquezcopybara-github
authored andcommitted
fix(menu): make overriding default styles less likely
fixes #4160 A workaround to lessen the likelihood of someone's styles clashing with the default light dom styles of md-menu and md-select. It's difficult to tell whether a slotted element will animate and fire animation events, so tihs is a bit of a workaround for now. PiperOrigin-RevId: 558910594
1 parent ab3aa41 commit 626b4ef

File tree

2 files changed

+7
-7
lines changed

2 files changed

+7
-7
lines changed

menu/internal/_menu.scss

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@
9595
overflow: hidden;
9696
}
9797

98-
&.animating ::slotted(.hidden) {
98+
&.animating ::slotted(.md-menu-hidden) {
9999
opacity: 0;
100100
}
101101

menu/internal/menu.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -481,9 +481,9 @@ export abstract class Menu extends LitElement {
481481

482482
// Make them all initially hidden and then clean up at the end of each
483483
// animation.
484-
child.classList.toggle('hidden', true);
484+
child.classList.toggle('md-menu-hidden', true);
485485
animation.addEventListener('finish', () => {
486-
child.classList.toggle('hidden', false);
486+
child.classList.toggle('md-menu-hidden', false);
487487
});
488488

489489
childrenAnimations.push([child, animation]);
@@ -494,7 +494,7 @@ export abstract class Menu extends LitElement {
494494
upPositionCorrectionAnimation.cancel();
495495
surfaceOpacityAnimation.cancel();
496496
childrenAnimations.forEach(([child, animation]) => {
497-
child.classList.toggle('hidden', false);
497+
child.classList.toggle('md-menu-hidden', false);
498498
animation.cancel();
499499
});
500500
});
@@ -596,7 +596,7 @@ export abstract class Menu extends LitElement {
596596
// Make sure the items stay hidden at the end of each child animation.
597597
// We clean this up at the end of the overall animation.
598598
animation.addEventListener('finish', () => {
599-
child.classList.toggle('hidden', true);
599+
child.classList.toggle('md-menu-hidden', true);
600600
});
601601
childrenAnimations.push([child, animation]);
602602
}
@@ -607,15 +607,15 @@ export abstract class Menu extends LitElement {
607607
surfaceOpacityAnimation.cancel();
608608
childrenAnimations.forEach(([child, animation]) => {
609609
animation.cancel();
610-
child.classList.toggle('hidden', false);
610+
child.classList.toggle('md-menu-hidden', false);
611611
});
612612
reject();
613613
});
614614

615615
surfaceHeightAnimation.addEventListener('finish', () => {
616616
surfaceEl.classList.toggle('animating', false);
617617
childrenAnimations.forEach(([child]) => {
618-
child.classList.toggle('hidden', false);
618+
child.classList.toggle('md-menu-hidden', false);
619619
});
620620
this.openCloseAnimationSignal.finish();
621621
this.dispatchEvent(new Event('closed'));

0 commit comments

Comments
 (0)