From ddbfe11e9698f5b252f6eb9d9997a1f88505faa2 Mon Sep 17 00:00:00 2001 From: Kristiyan Kostadinov Date: Sun, 25 Apr 2021 15:15:02 +0200 Subject: [PATCH] fix(material-experimental/mdc-list): avoid style conflicts with other list-based components Currently the styles for the MDC-based list are included globally which causes conflicts with other list-based components like `mat-select` and `mat-autocomplete`. This can be seen by going to the MDC list demo and then the MDC select demo, and observing that the option text is now truncated. These changes resolve the issue by nesting the styles under the `mat-mdc-list-base` class. --- .../mdc-list/_list-theme.scss | 8 +-- .../mdc-list/action-list.ts | 4 +- src/material-experimental/mdc-list/list.scss | 52 ++++++++++--------- src/material-experimental/mdc-list/list.ts | 4 +- .../mdc-list/nav-list.ts | 4 +- .../mdc-list/selection-list.ts | 4 +- 6 files changed, 41 insertions(+), 35 deletions(-) diff --git a/src/material-experimental/mdc-list/_list-theme.scss b/src/material-experimental/mdc-list/_list-theme.scss index bb5e33b9fb8b..8c18cfae1e86 100644 --- a/src/material-experimental/mdc-list/_list-theme.scss +++ b/src/material-experimental/mdc-list/_list-theme.scss @@ -13,9 +13,11 @@ @mixin color($config-or-theme) { $config: theming.get-color-config($config-or-theme); - // MDC's state styles are tied in with their ripple. Since we don't use the MDC - // ripple, we need to add the hover, focus and selected states manually. - @include interactive-list-theme.private-interactive-list-item-state-colors($config); + .mat-mdc-list-base { + // MDC's state styles are tied in with their ripple. Since we don't use the MDC + // ripple, we need to add the hover, focus and selected states manually. + @include interactive-list-theme.private-interactive-list-item-state-colors($config); + } @include mdc-helpers.mat-using-mdc-theme($config) { @include mdc-list.deprecated-without-ripple($query: mdc-helpers.$mat-theme-styles-query); diff --git a/src/material-experimental/mdc-list/action-list.ts b/src/material-experimental/mdc-list/action-list.ts index ed7f2df7d925..89c99420fdf5 100644 --- a/src/material-experimental/mdc-list/action-list.ts +++ b/src/material-experimental/mdc-list/action-list.ts @@ -12,9 +12,9 @@ import {MatListBase} from './list-base'; @Component({ selector: 'mat-action-list', exportAs: 'matActionList', - template: '', + template: '
', host: { - 'class': 'mat-mdc-action-list mat-mdc-list-base mdc-deprecated-list', + 'class': 'mat-mdc-action-list mat-mdc-list-base', }, styleUrls: ['list.css'], encapsulation: ViewEncapsulation.None, diff --git a/src/material-experimental/mdc-list/list.scss b/src/material-experimental/mdc-list/list.scss index 116807d9a15c..9f144d0ad643 100644 --- a/src/material-experimental/mdc-list/list.scss +++ b/src/material-experimental/mdc-list/list.scss @@ -3,12 +3,32 @@ @use '../../material/core/style/layout-common'; @use '../../cdk/a11y'; -@include mdc-list.deprecated-without-ripple($query: mdc-helpers.$mat-base-styles-query); - // MDC expects the list element to be a `