-
Notifications
You must be signed in to change notification settings - Fork 6.8k
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
fix(select): Arrow position/animation for appearance="standard" #12045
Conversation
src/demo-app/select/select-demo.html
Outdated
@@ -144,6 +144,59 @@ | |||
</mat-card-content> | |||
</mat-card> | |||
|
|||
<mat-card class=".demo-appearance-comparison"> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The dot in the class name looks like it shouldn't be there. Also it doesn't look like this class is being used anywhere.
src/lib/select/select-animations.ts
Outdated
/** | ||
* This animation moves the panel toggle arrow up whenever the select is not empty to match the | ||
* visual middle. This affects only mat-selects with appearance='standard'. | ||
*/ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Defining an animation just to move the arrow around is overkill and it makes it very hard for people to override the styles. Since the empty
state is on the mat-select
already, you can use it to toggle a class either on the select or the arrow itself which tells it where it's supposed to be positioned.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Using a normal CSS transition will make it easy to target the specific appearance as well, since the form field already has a class indicating the variant.
You can hook into the Angular Animations to disable this transition when Angular Animations are disabled. As an example see here: https://github.com/angular/material2/blob/master/src/lib/form-field/form-field.scss#L220
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, using just simple CSS seems way better and easier to handle - I'm gonna update the PR on the weekend!
src/demo-app/select/select-demo.html
Outdated
@@ -144,6 +144,59 @@ | |||
</mat-card-content> | |||
</mat-card> | |||
|
|||
<mat-card class=".demo-appearance-comparison"> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you add a button to this demo that allows me to toggle all of the selects to either have a value or be cleared? It's tough to see the animation when manually selecting the value
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure, will do!
src/lib/select/select-animations.ts
Outdated
/** | ||
* This animation moves the panel toggle arrow up whenever the select is not empty to match the | ||
* visual middle. This affects only mat-selects with appearance='standard'. | ||
*/ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Using a normal CSS transition will make it easy to target the specific appearance as well, since the form field already has a class indicating the variant.
You can hook into the Angular Animations to disable this transition when Angular Animations are disabled. As an example see here: https://github.com/angular/material2/blob/master/src/lib/form-field/form-field.scss#L220
Alright! Switched over to a simple css animation and added a toggle button to the select-demo to quickly see the effect. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this feature looks good and is limited-scope enough to not interfere with adherence to the spec in other situations. Thanks for working on it!
@@ -202,6 +202,7 @@ export class MatSelectTrigger {} | |||
'[class.mat-select-disabled]': 'disabled', | |||
'[class.mat-select-invalid]': 'errorState', | |||
'[class.mat-select-required]': 'required', | |||
'[class.mat-select-empty]': 'empty', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
iirc, form-field has an empty class that you can probably use instead of adding a new one here
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey, just checked this out, but the .mat-form-field-empty is only set on the floating label, not the mat-form-field itself. What would be the best change @mmalerba?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh ok, in that case we can just leave it as is
…lar#11925) This commit aims to fix the arrow positioning of mat-selects with appearance="standard". Since the label moves down whenever the selected value is empty, the arrow looks out of place. I added an animation that matches the speed of the label animation: Going from filled to empty transitions the arrow down so that it sits level with the label. Going from empty to filled snaps the arrow back up, matching the label's behavior. To test/compare the different appearances I added another card to the demo-app with all of them.
6362302
to
4df3243
Compare
Heh, rebased onto current master again to trigger a new CI run, now circleci passes but travis failed. Could you look into it once again @mmalerba? |
failure looks like a flake, I restarted it |
This issue has been automatically locked due to inactivity. Read more about our automatic conversation locking policy. This action has been performed automatically by a bot. |
This commit aims to fix the arrow positioning of mat-selects
with appearance="standard". Since the label moves down whenever
the selected value is empty, the arrow looks out of place.
I added an animation that matches the speed of the label
animation:
sits level with the label.
label's behavior.
To test/compare the different appearances I added another card
to the demo-app with all of them.
Fixes #11925.