Open tamtakoe opened 6 years ago
Hi @tamtakoe! Thank you for submitting this issue. It would be great to provide a reproducible example. I hesitate to use setTimeout by default, but I will give it a try. Again an example would definitely help a lot!
Hey, @tamtakoe any update on this one? Is this still an issue? If yes, can you please a reproducible example?
maybe try setting focus on after view checked hook? I am still new to angular so I don't know much, but from what I found, the view might not be ready yet
Hi @m-te! Have you experienced the same issue?
Hi, nope, I was just looking around for a way to set focus on input, so I came across this, I eventually ended up using the #viewchild, element's focus() and ngAfterViewChecked way, using the nativeElement.focus() on ngOninit and directive didn't work, but afterViewChecked seems to be doing what I need it to do.
I can't give you example, because it is very specific. I used focus directive in the cell of infinity scroll table and it corrupted scroll. The same directive has same problem. Fortunately, there is good decision:
Use
setTimeout
! I made several components with focus (oi.select one of them) and I had same problems. In Angular, React, Vanilla etc. and I understood the main thing - newer use set focus withoutsetTimeout
. This is one of rare places where its use is justified