Skip to content

Commit 12a50c0

Browse files
hsourcefacebook-github-bot
authored andcommitted
Fixed TextInput not being selectable in removeClippedSubviews FlatLists (#28852)
Summary: This is a resubmit of D21499015. It resolves #28852 and #27787. From Harry Yu's original PR (too old to merge now): Text in TextInputs can't be selected by long press. This happens only when they're inside of FlatLists that are rendered with removeClippedSubview prop set to true on Android. Fixes #27787 Issue #6085 2 years ago had fixed this issue with a quick fix, but the code has since disappeared in another change. It has a longer explanation for why it's fixed, but essentially - the text is assumed to be not selectable since the TextInput is initialized without being attached to the window. We need to explicitly set the text to be selectable on attachment. This change redoes that change with a 1-line fix. Changelog: [Android] [Fixed] - Fixed TextInput not being selectable in removeClippedSubviews FlatLists Pull Request resolved: #28852 Test Plan: This can be tested with a new toggle in RNTesterApp. Go to the FlatList in RNTesterApp Toggle on "removeClippedSubviews" Try selecting some text in the list header. It should fail without this comment but succeed with it Reviewed By: sammy-SC Differential Revision: D24043533 Pulled By: JoshuaGross fbshipit-source-id: c8e60f8131ccc5f6af31ed976c4184d0a16eb3af
1 parent 7c83eab commit 12a50c0

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

ReactAndroid/src/main/java/com/facebook/react/views/textinput/ReactEditText.java

+7
Original file line numberDiff line numberDiff line change
@@ -827,6 +827,13 @@ public void onStartTemporaryDetach() {
827827
@Override
828828
public void onAttachedToWindow() {
829829
super.onAttachedToWindow();
830+
831+
// Used to ensure that text is selectable inside of removeClippedSubviews
832+
// See https://github.com/facebook/react-native/issues/6805 for original
833+
// fix that was ported to here.
834+
835+
super.setTextIsSelectable(true);
836+
830837
if (mContainsImages) {
831838
Spanned text = getText();
832839
TextInlineImageSpan[] spans = text.getSpans(0, text.length(), TextInlineImageSpan.class);

0 commit comments

Comments
 (0)