4

I am trying to set the focus to a textarea to make the keyboard appear on iOS but without luck. The textarea is inside a absolute positioned overlay.

I have the following code in the component file.

@ViewChild('textarea') textarea;

ngOnInit() {
  setTimeout(() => {            
        this.textarea.nativeElement.focus();
    }, 500);
}

ngAfterViewInit() {
    this.textarea.nativeElement.focus();
}

This works fine on desktop and when simulating iOS in Chrome, that is the textarea is successfully focused and the caret is blinking.

This doesn't work on the phone itself (iPhone 6, chrome)

I found this link iOS - Workaround for manually focusing on an input/textarea

and I removed all the webkit-user-select:none css. I also tried to change focus to click but without luck.

Any idea how I can set the focus to the textarea and make the softkeyboard appear on chrome in iOS?

Community
  • 1
  • 1
doorman
  • 15,707
  • 22
  • 80
  • 145

0 Answers0