Skip to content

Some sass selector expressions don't work when nested in a theme class #4077

@xmeng1

Description

@xmeng1

Bug, feature request, or proposal:

I have searched this problem and find #2662, but when I try to use it I found, the select component still has a problem.

After setting the theme for the overlay container, the overlying theme of select is changed.

However the problem is the Placeholder and the underline, the color is still the previous theme


I try to find the reason of the issue and find that there are some CSS define for the placeholder and underline as follows:

material2-master/src/lib/select/_select-theme.scss

.mat-select-trigger {
    color: mat-color($foreground, hint-text);

    .mat-select:focus:not(.mat-select-disabled) & {
      color: mat-color($primary);
    }

    .mat-select:not(:focus).ng-invalid.ng-touched:not(.mat-select-disabled) & {
      color: mat-color($warn);
    }
  }

  .mat-select-underline {
    background-color: mat-color($foreground, divider);

    .mat-select:focus:not(.mat-select-disabled) & {
      background-color: mat-color($primary);
    }

    .mat-select:not(:focus).ng-invalid.ng-touched:not(.mat-select-disabled) & {
      background-color: mat-color($warn);
    }
  }

So when the Select is focused, these CSS Pseudo-Classes is activated, and the color is the previous theme. I think all DOM add a class of new theme .xxxxx (such as .red-indigo), but the pseudo-class is activated, this new theme class is not added.

I try to solve it, but I cannot find the related code to add class to the DOM

I make a demo and deploy on Firebase

https://github.com/xmeng1/ng2-material-admin

https://ng2-material-admin.firebaseapp.com/

What is the expected behavior?

What is the current behavior?

What are the steps to reproduce?

Providing a Plunker (or similar) is the best way to get the team to see your issue.
Plunker template: https://goo.gl/DlHd6U

What is the use-case or motivation for changing an existing behavior?

Which versions of Angular, Material, OS, browsers are affected?

Is there anything else we should know?

Metadata

Metadata

Assignees

No one assigned

    Labels

    P2The issue is important to a large percentage of users, with a workaround

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions