Skip to content
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

feat(WKWebView): Allow focus without user interaction #540

Merged
merged 3 commits into from
Apr 29, 2019

Conversation

ericlewis
Copy link
Contributor

@ericlewis ericlewis commented Apr 26, 2019

Summary

This is an attempt at solving #278 for iOS. It introduces a new prop called keyboardDisplayRequiresUserAction. Setting it to false will allow the WebView to bring up the keyboard on focus events. It works on 9.0-12.2. It works by swizzling WKContentView, with different versions for the 11.3-12.20+ ranges.

Testing strategy

Created a new app using react-native init using my modified version, setting https://www.w3schools.com/jsref/tryit.asp?filename=tryjsref_text_autofocus as the source. When set to false, it would autofocus, when set to true it didn't. I also tried combining it with hideKeyboardAccessoryView which also swizzles, and all combinations worked fine.

Please let me know what else needs to be done, such as updating docs? Should I also update the UIWebView version? I don't have a lot of expertise in Android, but am happy to tackle that maybe next.

@jamonholmgren
Copy link
Member

Hey @ericlewis , thanks for this PR!

  • Don't bother with UIWebView
  • Docs would be awesome, and required before testing
  • Would you mind testing in iOS 9 and the iOS 11.3-12.2 range to ensure both of those code paths work?

Otherwise, I'm fine with this new property.

@ericlewis
Copy link
Contributor Author

iOS Simulator 11.4 seems to work

@ericlewis
Copy link
Contributor Author

iOS Simulator 12.2 works

@ericlewis
Copy link
Contributor Author

iOS Simulator 9.3 works

@Titozzz Titozzz changed the title [iOS] Allow focus without user interaction feat(WKWebView): Allow focus without user interaction Apr 29, 2019
@Titozzz Titozzz merged commit 455c30e into react-native-webview:master Apr 29, 2019
@Titozzz
Copy link
Collaborator

Titozzz commented Apr 29, 2019

@allcontributors[bot] please add @ericlewis for code,doc

@allcontributors
Copy link
Contributor

@Titozzz

I couldn't determine any contributions to add, did you specify any contributions?
Please make sure to use valid contribution names.

@Titozzz
Copy link
Collaborator

Titozzz commented Apr 29, 2019

@allcontributors[bot] please add @ericlewis for code doc

@allcontributors
Copy link
Contributor

@Titozzz

I've put up a pull request to add @ericlewis! 🎉

react-native-community-bot pushed a commit that referenced this pull request Apr 29, 2019
# [5.8.0](v5.7.2...v5.8.0) (2019-04-29)

### Features

* **WKWebView:** Allow focus without user interaction ([#540](#540)) ([455c30e](455c30e))
@react-native-community-bot
Copy link
Collaborator

🎉 This PR is included in version 5.8.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

@fungilation
Copy link
Contributor

Same keyboardDisplayRequiresUserAction on Android too would be awesome!

phuongwd pushed a commit to phuongwd/react-native-webview that referenced this pull request Apr 29, 2020
…ebview#540)

* [iOS] Allow focus without user interaction

* Add documentation for keyboardDisplayRequiresUserAction

* set keyboardDisplayRequiresUserAction default to true
phuongwd pushed a commit to phuongwd/react-native-webview that referenced this pull request Apr 29, 2020
noproblem23 added a commit to noproblem23/react-native-webview that referenced this pull request Apr 18, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants