-
Notifications
You must be signed in to change notification settings - Fork 6.8k
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
Focus is not working in iOS devices #15317
Comments
@MSAppsDev It seems that the problem comes from the browsers itself. You can see here that it is not specified if the mobile browser versions supports focus at all. |
@Aleksandyr , thanks for your time and the link that lists the browser support for native focus, yes sample works fine in IE and Chrome in both mobile and desktop but not on iOS devices. I did looked into the link before posting the question but wanted to know if anyone achieved this in angular? i know it can be done in react and vue. |
@MSAppsDev I have modified the sample in order to work with IOS devices and I have tested it with IOS 12.1.4 Safari 12 and it worked perfectly for me. Could you please open the modified sample with IOS device and try to reproduce the problem again? I have also created a video which is showing how to sample works. |
Hi @Aleksandyr, I updated "shouldFocus" variable to "true" then i got below error ERROR to avoid above error i updated ngAfterViewChecked as below ngAfterViewChecked() { with this change i see the focus is going to Input1 by default on Desktop (IE & chrome) but not on Mobile devices. However ngAfterVIewChecked is called every time Angular has finished running change detection on a component and it's children where as ngAfterViewInit is called only during first change detection cycle. So i moved ngAfterViewChecked() code to ngAfterViewInit() but it didn't work on mobile devices. It sets the focus and shows keyboard on a button click event but not with non user interaction event.
|
Hello @MSAppsDev Sorry about my misunderstanding. I faced the problem you have and that's what I've found during my research.
|
Hi @Aleksandyr , Thanks for your time. Currently i don't have React & Vue environment to replicate the issue. |
@MSAppsDev I think it would be more appropriate if you refer the issue to the angular/angular repository. @crisbeto @jelbourn Do you have any suggestions on how we could proceed with the issue? |
This is unrelated to Angular Material, and I suspect unrelated to Angular as well. My guess would be that it's unrelated to Angular as well |
This issue has been automatically locked due to inactivity. Read more about our automatic conversation locking policy. This action has been performed automatically by a bot. |
What is the expected behavior?
setting focus should work across all devices
What is the current behavior?
its not working in iOS devices.
What are the steps to reproduce?
add a input field into angular reactive form, create a element ref to input field in type script then call
this.inputelementref.nativeElement.focus() in afterViewInit() event of the angular component.
see the sample code
https://stackblitz.com/edit/angular-xpweac
Which versions of Angular, Material, OS, TypeScript, browsers are affected?
Angular 5+ (not sure about lower versions), iOS 12+, Safari & Chrome on iOS.
Is there anything else we should know?
The text was updated successfully, but these errors were encountered: