Skip to content

Commit

Permalink
fix(multiple): incosistent item text truncation when used together wi…
Browse files Browse the repository at this point in the history
…th 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)
  • Loading branch information
crisbeto authored and amysorto committed Jul 16, 2021
1 parent d112acb commit 48739eb
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/material-experimental/mdc-core/option/optgroup.scss
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,10 @@
// we can't use directly, because it comes with some selectors.
opacity: mdc-list-variables.$content-disabled-opacity;
}

// Needs to be overwritten explicitly, because the style can
// leak in from the list and cause the text to truncate.
.mdc-list-item__primary-text {
white-space: normal;
}
}
6 changes: 6 additions & 0 deletions src/material-experimental/mdc-core/option/option.scss
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,12 @@
// Pointer events can be safely disabled because the ripple trigger element is the host element.
pointer-events: none;
}

// Needs to be overwritten explicitly, because the style can
// leak in from the list and cause the text to truncate.
.mdc-list-item__primary-text {
white-space: normal;
}
}

.mat-mdc-option-active {
Expand Down
6 changes: 6 additions & 0 deletions src/material-experimental/mdc-menu/menu.scss
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,12 @@ mat-menu {
}
}

// Needs to be overwritten explicitly, because the style can
// leak in from the list and cause the text to truncate.
.mdc-list-item__primary-text {
white-space: normal;
}

@include a11y.high-contrast(active, off) {
$outline-width: 1px;

Expand Down

0 comments on commit 48739eb

Please sign in to comment.