Skip to content

Tapping into PlainText doesn't allow to select text on Android #267

@mzorz

Description

@mzorz

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.

gutenberg_plain_text_selection_not_ok

Leaving information about the experiments done here:

  1. 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 TextInput becomes possible.

gutenberg_as_is_rotate

  1. 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.

  2. Back to the context of using TextInput in RecyclerViewList, 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.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions