Skip to content

Commit 08fada5

Browse files
committed
fix(material/list): list item truncates on narrow screen widths
Fixes issue with Angular Components List component where the list item truncates on narrow screen widths (ie. mobile screens). Removes white-space wrap style and adds some height to primary lines for readability. Fixes b/291296866
1 parent 5398170 commit 08fada5

File tree

1 file changed

+16
-6
lines changed

1 file changed

+16
-6
lines changed

src/material/list/list.scss

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -162,15 +162,24 @@ a.mdc-list-item--activated {
162162
}
163163
}
164164

165-
.mat-mdc-list-item.mdc-list-item--with-three-lines {
166-
// List item lines or titles never wrap. MDC always enables wrapping for secondary text
167-
// if the list item has acquired three lines. We unset these styles for line elements.
168-
// https://github.com/material-components/material-components-web/blob/348665978ce73694ad4518626dd70cdf5b984113/packages/mdc-list/_evolution-mixins.scss#L205-L206.
169-
// TODO: Consider removing once MDC supports the explicit tertiary line list variant.
165+
.mat-mdc-list-item.mdc-list-item--with-leading-avatar.mdc-list-item--with-two-lines
166+
.mdc-list-item__primary-text::before {
167+
height: 25px;
168+
}
169+
170+
.mat-mdc-list-item.mdc-list-item--with-three-lines,
171+
.mat-mdc-list-item.mdc-list-item--with-two-lines {
172+
// List item lines must wrap according to GAR 1.18(b). Removing the nowrap and
173+
// adjusts .mat-mdc-list-item-title.mdc-list-item__primary-text height
174+
// to accommodate any wrapping text. Fixes: b/247881646.
175+
.mat-mdc-list-item-title.mdc-list-item__primary-text,
170176
.mat-mdc-list-item-line.mdc-list-item__secondary-text {
171-
white-space: nowrap;
177+
white-space: normal;
172178
line-height: normal;
173179
}
180+
.mat-mdc-list-item-title.mdc-list-item__primary-text {
181+
height: 45px;
182+
}
174183

175184
// Unscoped content can wrap if the list item has acquired three lines. MDC implements
176185
// this functionality for secondary text but there is no proper text ellipsis when
@@ -218,3 +227,4 @@ mat-action-list button {
218227
}
219228
}
220229
}
230+

0 commit comments

Comments
 (0)