components icon indicating copy to clipboard operation
components copied to clipboard

input placeholder covers value when using OnPush detection strategy

Open fxck opened this issue 9 years ago • 20 comments

I know there were couple of these before, but it seems to be happening again https://gist.run/?id=d815c9d4e98685976793d074fcc89c23

cc @kara @mmalerba maybe?

fxck avatar Feb 09 '17 11:02 fxck

I have the exactly same issue on my project that the placeholder value overlap with the input value.

johnqiuwan avatar Feb 12 '17 02:02 johnqiuwan

I have the same issue when using reactive forms yForm.controls['xControl'].setValue('foobar')

issue gif

If I dont change the input using the keyboard, the input just puts the placeholder back to its original position as if the input is empty which its not.

abdel-ships-it avatar Feb 13 '17 12:02 abdel-ships-it

There are some similar issues to this one that have already been fixed (#2816, #2837). This one only applies if you are using ChangeDetectionStrategy.OnPush

mmalerba avatar Feb 13 '17 18:02 mmalerba

I'm seeing this manifest in browser-populated fields - specifically userName and password fields populated by Chrome et. al. My normal temporary hack of

setTimeout(() => { this.changeDetectorRef.markForCheck() }, 100)

fails for this case, however.

Edit: It's a bit more of an edge case than I realised. It only happens if the page is not currently focused - presumably related to the fact that the change listener doesn't fire either, in the same case. To reproduce I have to have the cursor in the address bar and hit enter. The page reloads the label is covering the auto-populated password field. Using keyboard shortcuts to refresh while focused on the console pane causes it also. The placeholder jumps into the correct place as soon as the page body gets focus.

ggranum avatar Mar 16 '17 16:03 ggranum

I'm also seeing this behavior not only for input but on select as well when using OnPush. The select control doesn't have it's value selected until a form control is given focus. Similar to what @realappie shows.

onpushbug

JacobBrandt avatar Mar 18 '17 18:03 JacobBrandt

maybe related to #2663 says it's fixed but i'm still having this issue using select in combination with reactive forms/OnPush change detection.( Angular 4.0.0, material 2.0.0.beta2)

mjolk avatar Mar 30 '17 13:03 mjolk

for me this all works as expected now.(beta 3) Good work!

mjolk avatar Apr 08 '17 15:04 mjolk

@mjolk , can you share how did was it fixed for you? i still can't have it working. take a look at this: https://plnkr.co/edit/FncXapgEEdqJU7R3kU8X?p=preview

eyalewin-zz avatar Apr 09 '17 09:04 eyalewin-zz

@mjolk What you do for OnPush work with input placeholder, i have last version (2.0.0-beta.3) and the problem persist.

FilipeQ avatar Apr 28 '17 11:04 FilipeQ

Still an issue for me as well. I've worked around it with:

setTimeout(() => {
      changeDetectorRef.markForCheck()
    }, 100)

In ngOnInit / ngAfterViewInit.

ggranum avatar Apr 28 '17 12:04 ggranum

@ggranum solution worked out for me, just that I've put it in the subscribe where the actual data is rendered. but still, I would have expected that this issue has been solved.

eyalewin-zz avatar May 17 '17 12:05 eyalewin-zz

i use markForCheck() as well, not specifically for this reason , but it apparently was the reason it worked( before in the exact same setup it didn't). It is logical( to me in my use case) the render does not happen without marking the component dirty( in a situation where there is new data from a subscription) manually so i did not think it was a bug/it was fixed

mjolk avatar May 22 '17 09:05 mjolk

I came to report the same issue - glad I searched before creating a new one. Here's my plunker for good measure

https://plnkr.co/edit/laqgCj3vQI8PPbnXc4en?p=preview

radoslavpetranov avatar May 23 '17 21:05 radoslavpetranov

Still seeing this issue: https://github.com/angular/material2/issues/4814

YeomansIII avatar May 30 '17 20:05 YeomansIII

I am still facing issue even with timeout hack. Is there anything else can be done to fix? (OnPush + ngModel)

taokakao avatar Jun 02 '17 19:06 taokakao

This problem back in beta.10. Can anybody solve it?

MaickelHubner avatar Sep 05 '17 14:09 MaickelHubner

@MaickelHubner can you reproduce it and open a new issue?

willshowell avatar Sep 05 '17 14:09 willshowell

This problem is back in beta 12, any solution?

jososaga avatar Oct 16 '17 19:10 jososaga

Would be great to have a solution because as it is now its not possible to use fields(( ... It was working fine in beta 11 ..

MaxTheMax2007 avatar Oct 31 '17 09:10 MaxTheMax2007

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.