I am creating an app using Angular2+ where I would like to smooth scroll to an input then set the focus to that input. I am doing something like this:
scroll(id){
document.getElementById(id).scrollIntoView({block: "start", behavior: "smooth"});
document.getElementById(id).focus();
}
The smooth scrolling part works fine until I add the focus code. I think what is happening is that when I set the focus it overrides the scrolling effect. How can I let the scrolling finish before I set the focus?
Here is code demonstrating what I mean: https://stackblitz.com/edit/angular-t4ousw