File tree Expand file tree Collapse file tree 9 files changed +49
-29
lines changed Expand file tree Collapse file tree 9 files changed +49
-29
lines changed Original file line number Diff line number Diff line change 18
18
// items so we have to grey them out ourselves.
19
19
.mat-mdc-menu-item [disabled ] {
20
20
& ,
21
- & ::after ,
21
+ .mat-mdc-menu-submenu-icon ,
22
22
.mat-icon-no-color {
23
23
@include mdc-theme .prop (color , text- disabled- on- background);
24
24
}
27
27
// Since we're creating `mat-icon` and the submenu trigger
28
28
// chevron ourselves, we have to handle the color as well.
29
29
.mat-mdc-menu-item .mat-icon-no-color ,
30
- .mat-mdc-menu-item- submenu-trigger ::after {
30
+ .mat-mdc-menu-submenu-icon {
31
31
@include mdc-theme .prop (color , text- icon- on- background);
32
32
}
33
33
Original file line number Diff line number Diff line change 3
3
[matRippleDisabled] ="disableRipple || disabled "
4
4
[matRippleTrigger] ="_getHostElement() ">
5
5
</ div >
6
+ < svg
7
+ *ngIf ="_triggersSubmenu "
8
+ class ="mat-mdc-menu-submenu-icon "
9
+ viewBox ="0 0 5 10 "
10
+ focusable ="false "> < polygon points ="0,0 5,5 0,10 "/> </ svg >
Original file line number Diff line number Diff line change @@ -98,11 +98,14 @@ mat-menu {
98
98
}
99
99
}
100
100
101
- // Renders out a chevron on menu items that trigger a sub-menu.
102
101
.mat-mdc-menu-item-submenu-trigger {
103
102
@include menu-common .item-submenu-trigger (mdc-list .$deprecated-side-padding );
104
103
}
105
104
105
+ .mat-mdc-menu-submenu-icon {
106
+ @include menu-common .item-submenu-icon (mdc-list .$deprecated-side-padding );
107
+ }
108
+
106
109
// Increase specificity because ripple styles are part of the `mat-core` mixin and can
107
110
// potentially overwrite the absolute position of the container.
108
111
.mat-mdc-menu-item .mat-mdc-menu-ripple {
Original file line number Diff line number Diff line change @@ -2070,7 +2070,9 @@ describe('MDC-based MatMenu', () => {
2070
2070
const menuItems = overlay . querySelectorAll ( '[mat-menu-item]' ) ;
2071
2071
2072
2072
expect ( menuItems [ 0 ] . classList ) . toContain ( 'mat-mdc-menu-item-submenu-trigger' ) ;
2073
+ expect ( menuItems [ 0 ] . querySelector ( '.mat-mdc-menu-submenu-icon' ) ) . toBeTruthy ( ) ;
2073
2074
expect ( menuItems [ 1 ] . classList ) . not . toContain ( 'mat-mdc-menu-item-submenu-trigger' ) ;
2075
+ expect ( menuItems [ 1 ] . querySelector ( '.mat-mdc-menu-submenu-icon' ) ) . toBeFalsy ( ) ;
2074
2076
} ) ;
2075
2077
2076
2078
it ( 'should increase the sub-menu elevation based on its depth' , ( ) => {
Original file line number Diff line number Diff line change 1
- @use ' ./private ' ;
1
+ @use ' ../../../cdk/a11y ' ;
2
2
@use ' ./list-common' ;
3
3
@use ' ./layout-common' ;
4
4
@@ -58,36 +58,34 @@ $icon-margin: 16px !default;
58
58
}
59
59
}
60
60
61
- @mixin item-submenu-trigger ($side-padding , $triangle-height : 10 px ) {
61
+ @mixin item-submenu-trigger ($side-padding ) {
62
62
// Increase the side padding to prevent the indicator from overlapping the text.
63
63
padding-right : $side-padding * 2 ;
64
64
65
- // Renders a triangle to indicate that the menu item will open a sub-menu.
66
- & ::after {
67
- $size : private .private-div ($triangle-height , 2 );
68
-
69
- width : 0 ;
70
- height : 0 ;
71
- border-style : solid ;
72
- border-width : $size 0 $size $size ;
73
- border-color : transparent transparent transparent currentColor ;
74
- content : ' ' ;
75
- display : inline-block ;
76
- position : absolute ;
77
- top : 50% ;
78
- right : $side-padding ;
79
- transform : translateY (-50% );
80
- }
81
-
82
65
[dir = ' rtl' ] & {
83
66
padding-right : $side-padding ;
84
67
padding-left : $side-padding * 2 ;
68
+ }
69
+ }
85
70
86
- & ::after {
87
- right : auto ;
88
- left : $side-padding ;
89
- transform : rotateY (180deg ) translateY (-50% );
90
- }
71
+ @mixin item-submenu-icon ($side-padding ) {
72
+ position : absolute ;
73
+ top : 50% ;
74
+ right : $side-padding ;
75
+ transform : translateY (-50% );
76
+ width : 5px ;
77
+ height : 10px ;
78
+ fill : currentColor ;
79
+
80
+ [dir = ' rtl' ] & {
81
+ right : auto ;
82
+ left : $side-padding ;
83
+ transform : translateY (-50% ) scaleX (-1 );
84
+ }
85
+
86
+ // Fix for Chromium-based browsers blending in the `currentColor` with the background.
87
+ @include a11y .high-contrast (active , off) {
88
+ fill : CanvasText;
91
89
}
92
90
}
93
91
Original file line number Diff line number Diff line change 21
21
22
22
& [disabled ] {
23
23
& ,
24
- & ::after ,
24
+ .mat-menu-submenu-icon ,
25
25
.mat-icon-no-color {
26
26
color : theming .get-color-from-palette ($foreground , ' disabled' );
27
27
}
28
28
}
29
29
}
30
30
31
31
.mat-menu-item .mat-icon-no-color ,
32
- .mat-menu-item- submenu-trigger ::after {
32
+ .mat-menu-submenu-icon {
33
33
color : theming .get-color-from-palette ($foreground , ' icon' );
34
34
}
35
35
Original file line number Diff line number Diff line change 3
3
[matRippleDisabled] ="disableRipple || disabled "
4
4
[matRippleTrigger] ="_getHostElement() ">
5
5
</ div >
6
+
7
+ < svg
8
+ *ngIf ="_triggersSubmenu "
9
+ class ="mat-menu-submenu-icon "
10
+ viewBox ="0 0 5 10 "
11
+ focusable ="false "> < polygon points ="0,0 5,5 0,10 "/> </ svg >
Original file line number Diff line number Diff line change @@ -77,6 +77,10 @@ mat-menu {
77
77
@include menu-common .item-submenu-trigger (menu-common .$side-padding );
78
78
}
79
79
80
+ .mat-menu-submenu-icon {
81
+ @include menu-common .item-submenu-icon (menu-common .$side-padding );
82
+ }
83
+
80
84
button .mat-menu-item {
81
85
width : 100% ;
82
86
}
Original file line number Diff line number Diff line change @@ -2055,7 +2055,9 @@ describe('MatMenu', () => {
2055
2055
const menuItems = overlay . querySelectorAll ( '[mat-menu-item]' ) ;
2056
2056
2057
2057
expect ( menuItems [ 0 ] . classList ) . toContain ( 'mat-menu-item-submenu-trigger' ) ;
2058
+ expect ( menuItems [ 0 ] . querySelector ( '.mat-menu-submenu-icon' ) ) . toBeTruthy ( ) ;
2058
2059
expect ( menuItems [ 1 ] . classList ) . not . toContain ( 'mat-menu-item-submenu-trigger' ) ;
2060
+ expect ( menuItems [ 1 ] . querySelector ( '.mat-menu-submenu-icon' ) ) . toBeFalsy ( ) ;
2059
2061
} ) ;
2060
2062
2061
2063
it ( 'should increase the sub-menu elevation based on its depth' , ( ) => {
You can’t perform that action at this time.
0 commit comments