Skip to content

Placeholder still covers input value in some cases #2837

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
abdulhaq-e opened this issue Jan 27, 2017 · 2 comments
Closed

Placeholder still covers input value in some cases #2837

abdulhaq-e opened this issue Jan 27, 2017 · 2 comments

Comments

@abdulhaq-e
Copy link

Bug, feature request, or proposal:

Bug (I think)

What is the expected behavior?

For mdInput to work properly. If a value exists in the box then the placeholder should be over it not on it.

What is the current behavior?

The placeholder is inside the box even though there is a value bound to the input.

What are the steps to reproduce?

http://plnkr.co/edit/eyN8D8oZuEwDhHLINsZ5?p=preview

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

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

latest Material build from master branch

Is there anything else we should know?

The main issue has been solved by #2455, I'm not sure if this is a bug or not. In my example, once the observable emits 4, the child component gets this value, it shows it on the view and the input also sets its value to 4 but NG is not aware of the change. It needs another change detection cycle to do so (e.g. by clicking in one of the fields).

@kara
Copy link
Contributor

kara commented Feb 1, 2017

@abdulhaq-e In the plunker, you're changing the value in the AfterViewChecked hook, which by definition runs after change detection. This is why the view is not updated.

If you change your code to use the ngOnChanges hook, it will update the value every time your @input changes but before change detection runs. This way, the placeholder state will update at the right time.

@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

2 participants