Skip to content

Commit 7297fde

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 98d4799 commit 7297fde

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
@@ -42,6 +42,28 @@
4242
}
4343
}
4444

45+
// Remove the browser button appearance for action list button items. These
46+
// buttons should appear as if they were standard Material Design list items.
47+
.mat-mdc-action-list button.mdc-list-item {
48+
background: none;
49+
color: inherit;
50+
border: none;
51+
font: inherit;
52+
outline: inherit;
53+
-webkit-tap-highlight-color: transparent;
54+
// Set the text alignment to "start" as buttons align their content
55+
// centered by default. List content is aligned on the start.
56+
text-align: left;
57+
58+
[dir='rtl'] & {
59+
text-align: right;
60+
}
61+
62+
&::-moz-focus-inner {
63+
border: 0;
64+
}
65+
}
66+
4567
// MDC supports avatars, but it's a per-list setting, whereas ours applies to individual
4668
// items. Therefore, we need to add our own styles.
4769
.mat-mdc-list-avatar {

src/material/list/list.scss

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

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

283285
[dir='rtl'] & {

0 commit comments

Comments
 (0)