-
Notifications
You must be signed in to change notification settings - Fork 57
Tapping into PlainText doesn't allow to select text on Android #267
Description
Creating issue here to keep track of scenarios tested and make a specific case for the solution built in PR #265.
Trying Gutenberg as is, realized that it was difficult (or impossible) to select text on PlainText-backed blocks (that is currently Code and More blocks).
The caret would appear upon touching, but not the context menu to select / copy / paste.
Leaving information about the experiments done here:
- I noted that just opening the demo app, rotating the device to horizontal and then rotating it back to vertical will make the issue go away - try doing it and then selecting text on any
TextInputbecomes possible.
-
so as a workaround, it seems the component needs to re-render itself, for that I tried a hack as described here [Android] Can't select text in TextInput facebook/react-native#9958 (comment) that simply sets the width of the InputText to 99% and then after having the component attached to the window we reset the state to force a redraw. This effectively makes the field's content selectable again.
-
Back to the context of using
TextInputinRecyclerViewList, I found out the workaround does not work for the elements that are not actually drawn on the screen when the list is shown (that is, the elements in the RecyclerViewList that are off the screen on startup). For example, try showing the keyboard and letting it up. Now reload the app, and try scrolling down the list and selecting one of the items that was “behind” the keyboard. You’ll see the text cannot be selected there.
One possible solution is to listen into the the adapter’s onViewAttachedToWindow(viewholder) callback and try to refresh the EditText there.

