Skip to content
This repository was archived by the owner on Apr 2, 2018. It is now read-only.

Focus on ion-input not properly working on WKWebview #274

Closed
polcham opened this issue May 14, 2017 · 24 comments
Closed

Focus on ion-input not properly working on WKWebview #274

polcham opened this issue May 14, 2017 · 24 comments

Comments

@polcham
Copy link

polcham commented May 14, 2017

Description:
Focusing and typing on an ion-input element in doesn't properly scroll up and focus on the input. There are instances where the texts typed cannot be seen because the keyboard covers the input. Removing WKWebview plugin fixes the focus and scrolling issue.

How to replicate:
Install cordova-plugin-wkwebview-engine plugin, create a form with an ion-input element then focus/type on the ion-input.

Environment:
Ionic Framework Version: 3.1.1
ionic-plugin-keyboard 2.2.1 "Keyboard"
cordova-plugin-wkwebview-engine 1.1.3 "Cordova WKWebView Engine"

@michaelpeterlee
Copy link

WkWebView does not respond to .focus()

Eg. document.getElementById('search-input').focus();

We can live without that, however need a solution to another [possibly-related] problem where scrolling is disabled after keyboard is triggered. We have to rotate aspect for it to scroll again.

@danielalvenstrand
Copy link

+1
Really need this to work, is there a workaround for wkwebview that anyone knows of? In no possible way I can get the keyboard to programatically open on an input-field.

@michaelpeterlee
Copy link

michaelpeterlee commented Jun 22, 2017

Re: ccorcos/cordova-plugin-wkwebview-engine@e994874

Make these changes to your CDVWKWebViewEngine.m

This solves the focus issue.

michaelpeterlee referenced this issue in ccorcos/cordova-plugin-wkwebview-engine Jun 22, 2017
@ccorcos
Copy link

ccorcos commented Jun 22, 2017

If you have some spare cycles, you can make a separate plugin that extends the WKWebViewEngine class -- that way we don't have to maintain a fork.

apache/cordova-plugin-wkwebview-engine#37 (comment)

@onderceylan
Copy link

I just created a class catalog as a cordova plugin to enable focus on WKWebView. You can install it from https://www.npmjs.com/package/cordova-plugin-wkwebview-inputfocusfix.

@ccorcos
Copy link

ccorcos commented Aug 21, 2017

Nice! Thanks @onderceylan

@ccorcos
Copy link

ccorcos commented Aug 22, 2017

@onderceylan do you know if this is possible for JS files as well? I have another PR, but I don't have any confidence it will get merged anytime soon: apache/cordova-plugin-wkwebview-engine#42

@onderceylan
Copy link

onderceylan commented Aug 23, 2017 via email

@ccorcos
Copy link

ccorcos commented Aug 23, 2017

No, I have another PR that allows you to dynamically set allowsBackForwardSwipeNavigation and it would be nice to do this "catalog class" thing rather than maintaining a fork.

@onderceylan
Copy link

@ccorcos I see your point. Yes, you should be able to call the category methods from js as well. When you use categories as I did on my extension plugin, you basically extend CDVWKWebViewEngine class. You should be able to use the same approach as you have on your fork.

@mlynch
Copy link
Contributor

mlynch commented Sep 20, 2017

Just merged a fix in our WKWebView plugin which resolves this: ionic-team/cordova-plugin-wkwebview-engine#171

Can someone try the latest version of the wkwebview plugin in master and confirm?

@shaliko
Copy link

shaliko commented Sep 23, 2017

@mlynch Works for me.

iOS 11

<preference name="KeyboardDisplayRequiresUserAction" value="false" />

autoFocusAssist: 'delay'

<ion-input type="text" autofocus clearInput></ion-input>

@onderceylan
Copy link

@mlynch It works for our apps, thanks for the merge.

@Fibonacci-Solucoes-Ageis

When this will be released? This is not working for me.

@hirbod
Copy link

hirbod commented Mar 31, 2018

Don't work on iOS 11.3 anymore. Is there any hotfix for it!?

@hirbod
Copy link

hirbod commented Mar 31, 2018

I just pushed a working PR
onderceylan/cordova-plugin-wkwebview-inputfocusfix#4

@mlynch
Copy link
Contributor

mlynch commented Mar 31, 2018 via email

@hirbod
Copy link

hirbod commented Mar 31, 2018

@mlynch I already pushed a PR into the Repo of @onderceylan

@mlynch
Copy link
Contributor

mlynch commented Mar 31, 2018 via email

@hirbod
Copy link

hirbod commented Mar 31, 2018

@mlynch not sure if this PR belongs to the keyboard plugin or the wkwebview-plugin, as the old fix seemed to be implemented (merged) but never released on the wkwebview-repo. We should first sort this out and I would love to provide a PR :)

@mlynch
Copy link
Contributor

mlynch commented Apr 1, 2018

Closing since this is a wk issue and I just pushed a fix for it ionic-team/cordova-plugin-ionic-webview@5ad40ae. Thanks for the help @hirbod

@mlynch mlynch closed this as completed Apr 1, 2018
@hirbod
Copy link

hirbod commented Apr 1, 2018

You're welcome @mlynch, and thanks for your fast action on this critical issue.

@hirbod
Copy link

hirbod commented Apr 1, 2018

@mlynch you might want to give credits for this to
https://stackoverflow.com/questions/32449870/programmatically-focus-on-a-form-in-a-webview-wkwebview/48623286#48623286

as I've just copied his answer and incorporated it.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

9 participants