-
Notifications
You must be signed in to change notification settings - Fork 6.8k
fix(material-experimental/mdc-form-field): missing styles for native select control #19140
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
jelbourn
merged 1 commit into
angular:master
from
devversion:feat/madc-form-field-native-select-styles
Apr 23, 2020
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
90 changes: 90 additions & 0 deletions
90
src/material-experimental/mdc-form-field/_form-field-native-select.scss
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
@import '../../cdk/a11y/a11y'; | ||
|
||
// Width of the Material Design form-field select arrow. | ||
$mat-form-field-select-arrow-width: 10px; | ||
// Height of the Material Design form-field select arrow. | ||
$mat-form-field-select-arrow-height: 5px; | ||
// Horizontal padding that needs to be applied to the native select in an form-field so | ||
// that the absolute positioned arrow does not overlap the select content. | ||
$mat-form-field-select-horizontal-end-padding: $mat-form-field-select-arrow-width + 5px; | ||
|
||
// Mixin that creates styles for native select controls in a form-field. | ||
@mixin _mat-form-field-native-select() { | ||
// Remove the native select down arrow and ensure that the native appearance | ||
// does not conflict with the form-field. e.g. Focus indication of the native | ||
// select is undesired since we handle focus as part of the form-field. | ||
select.mat-mdc-input-element { | ||
-moz-appearance: none; | ||
-webkit-appearance: none; | ||
background-color: transparent; | ||
display: inline-flex; | ||
box-sizing: border-box; | ||
|
||
// Hides the default arrow native selects. | ||
&::-ms-expand { | ||
display: none; | ||
} | ||
|
||
// By default the cursor does not change when hovering over a select. We want to | ||
// change this for non-disabled select elements so that it's more obvious that the | ||
// control can be clicked. | ||
&:not(:disabled) { | ||
cursor: pointer; | ||
} | ||
|
||
// As a part of its user agent styling, IE11 has a blue box inside each focused `select` | ||
// element which we have to reset. Note that this needs to be in its own selector, because | ||
// having it together with another one will cause other browsers to ignore it. | ||
&::-ms-value { | ||
// We need to reset the `color` as well, because IE sets it to white. | ||
color: inherit; | ||
background: none; | ||
|
||
// IE and Edge in high contrast mode reset the color for a focused select to the same color | ||
// as the background, however this causes it blend in because we've reset the `background` | ||
// above. We have to add a more specific selector in order to ensure that it gets the | ||
// `color` from our theme instead. | ||
@include cdk-high-contrast(active, off) { | ||
.mat-focused & { | ||
color: inherit; | ||
} | ||
} | ||
} | ||
} | ||
|
||
// Native select elements with the `matInput` directive should have Material Design | ||
// styling. This means that we add an arrow to the form-field that is based on the | ||
// Material Design specification. We achieve this by adding a pseudo element to the | ||
// form-field infix. | ||
.mat-mdc-form-field-type-mat-native-select { | ||
.mat-mdc-form-field-infix::after { | ||
content: ''; | ||
width: 0; | ||
height: 0; | ||
border-left: ($mat-form-field-select-arrow-width / 2) solid transparent; | ||
border-right: ($mat-form-field-select-arrow-width / 2) solid transparent; | ||
border-top: $mat-form-field-select-arrow-height solid; | ||
position: absolute; | ||
top: 50%; | ||
right: 0; | ||
|
||
// Make the arrow non-clickable so the user can click on the form control under it. | ||
pointer-events: none; | ||
|
||
[dir='rtl'] & { | ||
right: auto; | ||
left: 0; | ||
} | ||
} | ||
|
||
// Add padding on the end of the native select so that the content does not | ||
// overlap with the Material Design arrow. | ||
.mat-mdc-input-element { | ||
padding-right: $mat-form-field-select-horizontal-end-padding; | ||
[dir='rtl'] & { | ||
padding-right: 0; | ||
padding-left: $mat-form-field-select-horizontal-end-padding; | ||
} | ||
} | ||
} | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.