question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

md-option.mat-selected does not support multiple themes

See original GitHub issue

Bug, feature request, or proposal:

Bug

What is the expected behavior?

Should be able to style the selected md-option based on the currently selected theme

What is the current behavior?

Because the overlay for the select options are rendered outside of the Angular app element, theme-specific styles cannot be applied to the selected option.

What are the steps to reproduce?

With the following Sass theme setup:

@import '~@angular/material/_theming.scss';
@include mat-core();

$default-theme: mat-dark-theme(mat-palette($mat-green), mat-palette($mat-red));
@include angular-material-theme($default-theme);

.red-app {
    background-color: black;
    $red-app-primary: mat-palette($mat-red);
    $red-app-accent: mat-palette($mat-blue);
    $red-dark: mat-dark-theme($red-app-primary, $red-app-accent);
    @include angular-material-theme($red-dark);
}

.red-app .md-option.mat-selected.map-primary,
.red-app .mat-primary .mat-option.mat-selected {
    color: map-get($mat-red, 400);
}

The styles relative to .mat-selected will never be set because it is never rendered inside of an element containing the .red-app theme class:

md-select-styling-issue

For sample implementation, see http://material-platform.azurewebsites.net/select

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

md-option should be able to be styled by the currently active theme.

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

Given the nature of the way the overlay for md-option has been implemented, it would affect any version of Angular and TypeScript, as well as any OS and browser.

Material: 2.0.0-beta.7

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
willshowellcommented, Jul 5, 2017

@JaimeStill overlay components require a little extra setup for multiple styles

https://github.com/angular/material2/blob/master/guides/theming.md#multiple-themes-and-overlay-based-components

Did you update the themeClass?

0reactions
angular-automatic-lock-bot[bot]commented, Sep 6, 2019

This issue has been automatically locked due to inactivity. Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.

Read more comments on GitHub >

github_iconTop Results From Across the Web

angular - mat-theme is not working for mat-select options and ...
I'm currently working in an Angular 9 app with Angular Material and Custom Themes. Everything works except for ...
Read more >
Multiple Themes - AngularJS Material
In most applications, declaring multiple themes is not necessary. Instead, you should configure the default theme for your needs. If you need multiple...
Read more >
Select | Angular Material
Exported as: matSelect ... Whether the user should be allowed to select multiple options. ... Placeholder to be shown if no value has...
Read more >
angular/material2 - Gitter
Hello guys, I'm trying to use the autocomplete component, but I can not get it to work, if someone can help me please....
Read more >
Angular: How to Use Multiple Themes with Material? - OctoPerf
A complete tutorial on how to use multiple themes for Angular 11+ and Material Design. Two solutions are discussed with SCSS Mixins and...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found