Skip to content

Commit 457dd61

Browse files
crisbetoforsti0506
authored andcommitted
fix(material/list): not working correctly when list item is used as a button (angular#13617)
Based on our selector for `mat-list-item`, we allow it to be a `button`, however we don't do the necessary resets for it to be usable.
1 parent 6ef9189 commit 457dd61

File tree

1 file changed

+20
-19
lines changed

1 file changed

+20
-19
lines changed

src/material/list/list.scss

Lines changed: 20 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -203,6 +203,26 @@ $item-inset-divider-offset: 72px;
203203
}
204204
}
205205

206+
// We need some extra resets when the list items are buttons.
207+
button.mat-list-item, button.mat-list-option {
208+
padding: 0;
209+
width: 100%;
210+
background: none;
211+
color: inherit;
212+
border: none;
213+
outline: inherit;
214+
-webkit-tap-highlight-color: transparent;
215+
text-align: left;
216+
217+
[dir='rtl'] & {
218+
text-align: right;
219+
}
220+
221+
&::-moz-focus-inner {
222+
border: 0;
223+
}
224+
}
225+
206226
// This mixin adjusts the heights and padding based on whether the list is in dense mode.
207227
@mixin subheader-spacing($top-padding, $base-height) {
208228
height: $base-height;
@@ -270,25 +290,6 @@ $item-inset-divider-offset: 72px;
270290
}
271291

272292
mat-action-list {
273-
// Remove the native button look and make it look like a list item
274-
button {
275-
background: none;
276-
color: inherit;
277-
border: none;
278-
font: inherit;
279-
outline: inherit;
280-
-webkit-tap-highlight-color: transparent;
281-
text-align: left;
282-
283-
[dir='rtl'] & {
284-
text-align: right;
285-
}
286-
287-
&::-moz-focus-inner {
288-
border: 0;
289-
}
290-
}
291-
292293
.mat-list-item {
293294
cursor: pointer;
294295
outline: inherit;

0 commit comments

Comments
 (0)