Skip to content

Commit 6fd5034

Browse files
committed
refactor(material/list): fix action list CSS styles conflict with MDC-based list
The Angular Material action list has been styled using an element selector, instead of using the corresponding CSS class. This meant that the MDC-based list seemed to have a working action list, but in reality it was just working due to the leaked styles from the non-MDC list. This fixes the selector in the Angular Material list, and adds the necessary styles for the action list to the MDC list styles.
1 parent b682f84 commit 6fd5034

File tree

2 files changed

+25
-1
lines changed

2 files changed

+25
-1
lines changed

src/material-experimental/mdc-list/list.scss

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,28 @@
1010
display: block;
1111
}
1212

13+
// Remove the browser button appearance for action list button items. These
14+
// buttons should appear as if they were standard Material Design list items.
15+
.mat-mdc-action-list button.mdc-list-item {
16+
background: none;
17+
color: inherit;
18+
border: none;
19+
font: inherit;
20+
outline: inherit;
21+
-webkit-tap-highlight-color: transparent;
22+
// Set the text alignment to "start" as buttons align their content
23+
// centered by default. List content is aligned on the start.
24+
text-align: left;
25+
26+
[dir='rtl'] & {
27+
text-align: right;
28+
}
29+
30+
&::-moz-focus-inner {
31+
border: 0;
32+
}
33+
}
34+
1335
// MDC expects that the list items are always `<li>`, since we actually use `<button>` in some
1436
// cases, we need to make sure it expands to fill the available width.
1537
.mat-mdc-list-item,

src/material/list/list.scss

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -268,7 +268,7 @@ $item-inset-divider-offset: 72px;
268268
}
269269
}
270270

271-
mat-action-list {
271+
.mat-action-list {
272272
// Remove the native button look and make it look like a list item
273273
button {
274274
background: none;
@@ -277,6 +277,8 @@ mat-action-list {
277277
font: inherit;
278278
outline: inherit;
279279
-webkit-tap-highlight-color: transparent;
280+
// Set the text alignment to "start" as buttons align their content
281+
// centered by default. List content is aligned on the start.
280282
text-align: left;
281283

282284
[dir='rtl'] & {

0 commit comments

Comments
 (0)