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