-
Notifications
You must be signed in to change notification settings - Fork 3k
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() doesn't work in Android #1172
Comments
I'm having the same problem. There is a |
We also have the same problem. We did a workaround where we put above the editor a |
I tried to call
But there are new problems. Android does not actively pop up the keyboard after obtaining |
I have the same problem as you. When you switch the cursor from |
Is it theoretically possible to make this work? Or will Android refuse to open the keyboard and that's beyond our control? |
i'm having the same problem |
Please solve this :( |
Yes, in IOS work OK, but not in Android. |
Same issue, but I'm using QuillJS Rich Text Editor with WebView. It also uses editable div and I try to request focus on it programmatically with .focus(). On WEB version of our app it works fine. On iOS too. But Android performs selection of the text only. Keyboard is not appeared. Need additionally to click on WebView and whole text selection will be activated as expected. |
We'd love some help solving this issue from the community. Post a link to the PR here if you submit one. Thank you! |
Oops, didn't mean to close this. |
@stoica94 @Jakuubzmeko @Nice-zrd Can refer to |
The pell-rich method can only work in non-Expo apps, as Expo can't control keyboard visibility. |
@slapbox Environment:
|
I haven't given it a test, but wow that's crazy! How did you manage that @wxik? I took a look at the code here, but I don't quite understand how works. Thanks so much for sharing! |
A TextInput of size 1 and invisible is used, the TextInput Keyboard of focus will be opened, and then the focus in the webview is triggered, at this time the keyboard will remain open |
@stulip thanks for the explanation! If I understand correctly, it's not that Android users can't focus the |
Hello 👋, this issue has been opened for more than 2 months with no activity on it. If the issue is still here, please keep in mind that we need community support and help to fix it! Just comment something like still searching for solutions and if you found one, please open a pull request! You have 7 days until this gets closed automatically |
Not stale. |
You need to manually open the keyboard after the input is focused on android. It cannot be done automatically. A simple method on Native Side can do this probably. public static void showKeyboard(FragmentActivity activity) {
InputMethodManager inputMethodManager = (InputMethodManager) activity.getSystemService(Context.INPUT_METHOD_SERVICE);
inputMethodManager.toggleSoftInputFromWindow(activity.getCurrentFocus().getWindowToken(), InputMethodManager.SHOW_FORCED, 0);
} Its not optimised for React Native but that is how it will work, I once tried while I had a project where I was using Quill as an editor inside the WebView. |
@ammarahm-ed thanks for sharing! That seems very useful, but it's not something Expo users can leverage. It would be great if this was built into React Native Webview. |
I want to leave a comment here to write about my own approach to solving this problem, and although it is quite hacky, it seems to work like a charm.
I'm treating this solution with a grain of salt, but it seems to work. The temporary |
Dear everyone, I'm having the same issue. I need your helppppppppppppppppppppp!!!. I work on Expo CLI |
I can fixed this issue on Android. |
This should be neither stale nor closed, this is still very much an issue |
Here is the workaround solution I came up with based on // in
|
Bug description:
I am using react native rich text editor on both android and iOS. It uses webview component and it gets some javascript as a source. In the javascript I have defined some html and there ist a div, which is editable. By selecting this div and calling .focus() funcion I can focus it only on iOS not on Android and that's the problem, that after calling focus() in android id doesn't focus and doesn't show keyboard
To Reproduce:
I am using this rich text editor: https://github.com/stulip/react-native-pell-rich-editor
Expected behavior:
when I call .focus() in js, the div should be focused and show keyboard in android
Environment:
The text was updated successfully, but these errors were encountered: