Skip to content

BUG: md-input does not lift when setting form value #3101

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

Closed
chriseenberg opened this issue Feb 15, 2017 · 3 comments
Closed

BUG: md-input does not lift when setting form value #3101

chriseenberg opened this issue Feb 15, 2017 · 3 comments

Comments

@chriseenberg
Copy link

Bug

What is the expected behavior?

I expect the placeholder to lift above the text when there is an input, even when done programmatically.

What is the current behavior?

The placeholder stays down when setting value of an input field programmatically through from.controls.

What are the steps to reproduce?

Create a form with the form builder, then set a value like this:
Code to reproduce:
this.form = this.fb.group({ 'email': [null] })

<md-input-container class="form-full-width"> <input md-input placeholder="Email address" [formControl]="form.controls['email']"> </md-input-container>

this.form.controls['email'].setValue("[email protected]");

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

I want to be able to set a value of an input field and have it displayed right when i load some data.

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

Angular cli 1.0.0-beta.25.5, material: ^2.0.0-beta.1, Angular version: ^2.3.1

Is there anything else we should know?

I may be doing stuff wrong, as i would expect this bug to be caught sooner? please excuse me if this bug has already been reported.

Kind regards Chris

@fxck
Copy link
Contributor

fxck commented Feb 15, 2017

using OnPush by any chance?

#3005

@kara
Copy link
Contributor

kara commented Feb 15, 2017

If you're using 2.0.0-beta.1, you are probably seeing the setValue issue that has since been fixed in master. Testing in plunker with the master build, it seems to be working now: http://plnkr.co/edit/Z3AR9NqqD5cq8ymUF2ye?p=preview. As soon as we release, you should be able to upgrade to get the fix.

The exception is using setValue with an onPush change detection strategy, for which there is already an issue.

@kara kara closed this as completed Feb 15, 2017
@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 5, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants