Skip to content

fix(material-experimental/mdc-input): native select option blending in with background on dark themes - #19232

Merged
jelbourn merged 1 commit into
angular:masterfrom
crisbeto:mdc-form-field-dark-option-color
May 7, 2020
Merged

jelbourn merged 1 commit into
angular:masterfrom
crisbeto:mdc-form-field-dark-option-color

Conversation

@crisbeto

@crisbeto crisbeto commented May 2, 2020

Copy link
Copy Markdown
Member

On dark themes the color of the native select inside of an MDC-based form field is usually set to some shade of white. The problem is that the color of the native select dropdown preserves its white background, making the text invisible. These changes make it so that the options always use a dark text color.

@crisbeto crisbeto added P3 An issue that is relevant to core functions, but does not impede progress. Important, but not urgent merge safe target: patch This PR is targeted for the next patch release labels May 2, 2020
@googlebot googlebot added the cla: yes PR author has agreed to Google's Contributor License Agreement label May 2, 2020

@devversion devversion left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. I could imagine this also being part of the native-select mixin in the form-field. Mostly because non-theme styles for the select already live there.

That could help with style organization in the form-field, but I guess since the same code previously was in mat-input, it could be considered breaking.

@devversion devversion added the lgtm label May 4, 2020
@crisbeto

crisbeto commented May 4, 2020

Copy link
Copy Markdown
Member Author

We can't have this be in the native select mixin, because it's using theme colors.

@crisbeto crisbeto added the action: merge The PR is ready for merge by the caretaker label May 4, 2020
@devversion

Copy link
Copy Markdown
Member

Oh, I meant that we place it as a separate mixin in the dedicated native-select file. See how it's done for the subscript: https://github.com/angular/components/blob/master/src/material-experimental/mdc-form-field/_form-field-subscript.scss#L37.

@crisbeto

crisbeto commented May 4, 2020

Copy link
Copy Markdown
Member Author

We can't really do that, because we're inverting the color: we're using the light theme color for a dark theme. I don't think that MDC's API supports something like that.

@devversion

Copy link
Copy Markdown
Member

The snippet I sent just demonstrated that these dedicated files (for parts of a form-field) can have multiple mixins. It's totally possible to pass through a $theme or import these variables like you do right now. The only difference is that code specific to native select in form-fields is in a canonical place.

@crisbeto

crisbeto commented May 4, 2020

Copy link
Copy Markdown
Member Author

But then we'd be mixing non-theme styles with theming ones. I don't think we're doing that anywhere else, aside from the MDC form field.

@devversion

devversion commented May 4, 2020 •

Copy link
Copy Markdown
Member

That's fair. I don't consider this a big deal though. It makes more sense to me to group them by part, and not based on what is theme or not. That should be obvious enough based on mixin name.

I don't mind too much, I'm just saying that we are already doing this in the form field, and this one will fall out of that pattern. Maybe @mmalerba has a feeling on this.

In the initial form field PR I was asked to move this non-theme code into mixins; so since these files always are partials now, it should be fine having the theme mixin inside there too

@mmalerba mmalerba left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@include mat-using-mdc-theme($theme) {}
@include mat-using-mdc-theme($theme) {
.mat-mdc-input-element {
// On dark themes we set the native `select` color to some shade of white,

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm, I wonder if this will still be an issue if you have your browser in dark mode, or maybe it does some magic color inverting stuff for you - anyways if it is an issue it seems like a bigger thing than just this case

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just FYI: On macOS with the OS configured for dark mode (and Material using a dark mode), these styles are completely ignored for the native select dropdowns.

Screen Shot 2021-06-19 at 01 46 19

Even if I try to override these styles to red, it does nothing in the native select dropdown.

@mmalerba

mmalerba commented May 5, 2020

Copy link
Copy Markdown
Contributor

Oh sorry, I missed @devversion's comment. I think since there's already a precedent for doing it for other parts of the form field, it would be fine to make it a separate native select mixin

@mmalerba mmalerba removed the action: merge The PR is ready for merge by the caretaker label May 5, 2020
…ing in with background on dark themes

On dark themes the `color` of the native `select` inside of an MDC-based form field is usually set to some shade of white. The problem is that the color of the native `select` dropdown preserves its white background, making the text invisible. These changes make it so that the options always use a dark text color.
@crisbeto
crisbeto force-pushed the mdc-form-field-dark-option-color branch from a6d9022 to e0d481a Compare May 6, 2020 16:14
@crisbeto crisbeto added the action: merge The PR is ready for merge by the caretaker label May 6, 2020
@crisbeto

crisbeto commented May 6, 2020

Copy link
Copy Markdown
Member Author

Done.

@jelbourn
jelbourn merged commit d4a9624 into angular:master May 7, 2020
jelbourn pushed a commit that referenced this pull request May 7, 2020
…ing in with background on dark themes (#19232)

On dark themes the `color` of the native `select` inside of an MDC-based form field is usually set to some shade of white. The problem is that the color of the native `select` dropdown preserves its white background, making the text invisible. These changes make it so that the options always use a dark text color.
@angular-automatic-lock-bot

Copy link
Copy Markdown

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.

@angular-automatic-lock-bot angular-automatic-lock-bot Bot locked and limited conversation to collaborators Jun 7, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

action: merge The PR is ready for merge by the caretaker cla: yes PR author has agreed to Google's Contributor License Agreement P3 An issue that is relevant to core functions, but does not impede progress. Important, but not urgent target: patch This PR is targeted for the next patch release

6 participants