Skip to content

Commit 48739eb

Browse files
crisbetoamysorto
authored andcommitted
fix(multiple): incosistent item text truncation when used together with MDC list (#23138)
The MDC option, option group and menu share some styles with the MDC list, but deliberately exclude others in order to allow the text to wrap. The problem is that if an MDC list is seen first on the page, its styles will conflict with the others. These changes add an explicit override to avoid the conflict. (cherry picked from commit 6e1cede)
1 parent d112acb commit 48739eb

File tree

3 files changed

+18
-0
lines changed

3 files changed

+18
-0
lines changed

src/material-experimental/mdc-core/option/optgroup.scss

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,4 +19,10 @@
1919
// we can't use directly, because it comes with some selectors.
2020
opacity: mdc-list-variables.$content-disabled-opacity;
2121
}
22+
23+
// Needs to be overwritten explicitly, because the style can
24+
// leak in from the list and cause the text to truncate.
25+
.mdc-list-item__primary-text {
26+
white-space: normal;
27+
}
2228
}

src/material-experimental/mdc-core/option/option.scss

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,12 @@
6565
// Pointer events can be safely disabled because the ripple trigger element is the host element.
6666
pointer-events: none;
6767
}
68+
69+
// Needs to be overwritten explicitly, because the style can
70+
// leak in from the list and cause the text to truncate.
71+
.mdc-list-item__primary-text {
72+
white-space: normal;
73+
}
6874
}
6975

7076
.mat-mdc-option-active {

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,12 @@ mat-menu {
8282
}
8383
}
8484

85+
// Needs to be overwritten explicitly, because the style can
86+
// leak in from the list and cause the text to truncate.
87+
.mdc-list-item__primary-text {
88+
white-space: normal;
89+
}
90+
8591
@include a11y.high-contrast(active, off) {
8692
$outline-width: 1px;
8793

0 commit comments

Comments
 (0)