Skip to content

Commit b62ed3e

Browse files
committed
fix(material/list): not working correctly when list item is used as a button
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 23f3929 commit b62ed3e

File tree

1 file changed

+21
-19
lines changed

1 file changed

+21
-19
lines changed

src/material/list/list.scss

Lines changed: 21 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -203,6 +203,27 @@ $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+
font: inherit;
214+
outline: inherit;
215+
-webkit-tap-highlight-color: transparent;
216+
text-align: left;
217+
218+
[dir='rtl'] & {
219+
text-align: right;
220+
}
221+
222+
&::-moz-focus-inner {
223+
border: 0;
224+
}
225+
}
226+
206227
// This mixin adjusts the heights and padding based on whether the list is in dense mode.
207228
@mixin subheader-spacing($top-padding, $base-height) {
208229
height: $base-height;
@@ -270,25 +291,6 @@ $item-inset-divider-offset: 72px;
270291
}
271292

272293
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-
292294
.mat-list-item {
293295
cursor: pointer;
294296
outline: inherit;

0 commit comments

Comments
 (0)