File tree 2 files changed +26
-13
lines changed
2 files changed +26
-13
lines changed Original file line number Diff line number Diff line change @@ -64,17 +64,25 @@ mat-menu {
64
64
min-height : map .get ($height-config , default );
65
65
66
66
& [disabled ] {
67
- // Usually every click inside the menu closes it, however some browsers will stop events
68
- // when the user clicks on a disabled item, **except** when the user clicks on a non-disabled
69
- // child node of the disabled button. This is inconsistent because some regions of a disabled
70
- // button will still cause the menu to close and some won't (see #16694). We make the behavior
71
- // more consistent by disabling pointer events and allowing the user to click through.
72
- pointer-events : none ;
73
67
cursor : default ;
74
68
75
69
// This is the same as `mdc-list-mixins.list-disabled-opacity` which
76
70
// we can't use directly, because it comes with some selectors.
77
71
opacity : mdc-list-variables .$content-disabled-opacity ;
72
+
73
+ // The browser prevents clicks on disabled buttons from propagating which prevents the menu
74
+ // from closing, but clicks on child nodes still propagate which is inconsistent (see #16694).
75
+ // In order to keep the behavior consistent and prevent the menu from closing, we add an overlay
76
+ // on top of the content that will catch all the clicks while disabled.
77
+ & ::before {
78
+ display : block ;
79
+ position : absolute ;
80
+ content : ' ' ;
81
+ top : 0 ;
82
+ left : 0 ;
83
+ bottom : 0 ;
84
+ right : 0 ;
85
+ }
78
86
}
79
87
80
88
.mat-icon {
Original file line number Diff line number Diff line change @@ -49,13 +49,18 @@ mat-menu {
49
49
@include menu-common .item-base ();
50
50
position : relative ;
51
51
52
- & [disabled ] {
53
- // Usually every click inside the menu closes it, however some browsers will stop events
54
- // when the user clicks on a disabled item, **except** when the user clicks on a non-disabled
55
- // child node of the disabled button. This is inconsistent because some regions of a disabled
56
- // button will still cause the menu to close and some won't (see #16694). We make the behavior
57
- // more consistent by disabling pointer events and allowing the user to click through.
58
- pointer-events : none ;
52
+ // The browser prevents clicks on disabled buttons from propagating which prevents the menu
53
+ // from closing, but clicks on child nodes still propagate which is inconsistent (see #16694).
54
+ // In order to keep the behavior consistent and prevent the menu from closing, we add an overlay
55
+ // on top of the content that will catch all the clicks while disabled.
56
+ & [disabled ]::before {
57
+ display : block ;
58
+ position : absolute ;
59
+ content : ' ' ;
60
+ top : 0 ;
61
+ left : 0 ;
62
+ bottom : 0 ;
63
+ right : 0 ;
59
64
}
60
65
61
66
@include a11y .high-contrast (active , off) {
You can’t perform that action at this time.
0 commit comments