Skip to content

fix(form-field): label gap not being calculated when switching to outline dynamically #11658

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
merged 1 commit into from
Jul 10, 2018

Conversation

crisbeto
Copy link
Member

@crisbeto crisbeto commented Jun 4, 2018

Fixes the form field gap not being calculated if the field switches to the outline appearance after init.

Fixes #11653.

@crisbeto crisbeto requested a review from mmalerba as a code owner June 4, 2018 19:45
@googlebot googlebot added the cla: yes PR author has agreed to Google's Contributor License Agreement label Jun 4, 2018
@@ -148,6 +148,11 @@ export class MatFormField extends _MatFormFieldMixinBase
return this._appearance || this._defaultOptions && this._defaultOptions.appearance || 'legacy';
}
set appearance(value: MatFormFieldAppearance) {
// If we're switching to `outline` from another appearance, we have to recalculate the gap.
if (value !== this._appearance && value === 'outline') {
Copy link
Contributor

Choose a reason for hiding this comment

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

should we add a test for this?

Copy link
Member Author

Choose a reason for hiding this comment

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

I wasn't able to get it to measure the element within a unit test. IIRC I wasn't able to get that Promise.resolve to flush correctly.

Copy link
Contributor

Choose a reason for hiding this comment

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

did you try just doing a real async test?

Copy link
Member Author

@crisbeto crisbeto Jun 20, 2018

Choose a reason for hiding this comment

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

I got some time to take a better look and it turns out that my test wasn't working because it didn't have a label. I've pushed a test that fails when we expect it to.

…line dynamically

Fixes the form field gap not being calculated if the field switches to the `outline` appearance after init.

Fixes angular#11653.
@crisbeto crisbeto force-pushed the 11653/form-field-apperance-change branch from fbf28d9 to dc8ea5a Compare June 20, 2018 15:05
@mmalerba mmalerba added pr: lgtm action: merge The PR is ready for merge by the caretaker target: patch This PR is targeted for the next patch release labels Jul 3, 2018
@jelbourn jelbourn merged commit d75fa75 into angular:master Jul 10, 2018
victoriaaa234 pushed a commit that referenced this pull request Jul 25, 2018
…line dynamically (#11658)

Fixes the form field gap not being calculated if the field switches to the `outline` appearance after init.

Fixes #11653.
@angular-automatic-lock-bot
Copy link

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 Sep 9, 2019
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 target: patch This PR is targeted for the next patch release
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Floating label conflicts with outline when appearance is dynamically set
4 participants