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

Fixed TextInput not being selectable in removeClippedSubviews FlatLists #28852

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions RNTester/js/components/ListExampleShared.js
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,12 @@ class HeaderComponent extends React.PureComponent<{...}> {
<View style={styles.headerFooter}>
<Text>LIST HEADER</Text>
</View>
<View style={styles.headerInputContainer}>
<TextInput
defaultValue="Use this input to test text selection"
style={styles.headerInput}
/>
</View>
<SeparatorComponent />
</View>
);
Expand Down Expand Up @@ -281,6 +287,15 @@ const styles = StyleSheet.create({
headerFooterContainer: {
backgroundColor: 'rgb(239, 239, 244)',
},
headerInputContainer: {
backgroundColor: 'white',
margin: 5,
borderWidth: 1,
borderColor: '#cccccc',
},
headerInput: {
padding: 2,
},
listEmpty: {
alignItems: 'center',
justifyContent: 'center',
Expand Down
7 changes: 6 additions & 1 deletion RNTester/js/examples/FlatList/FlatListExample.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ type State = {|
fixedHeight: boolean,
logViewable: boolean,
virtualized: boolean,
removeClippedSubviews: boolean,
empty: boolean,
useFlatListItemComponent: boolean,
fadingEdgeLength: number,
Expand All @@ -71,6 +72,7 @@ class FlatListExample extends React.PureComponent<Props, State> {
fixedHeight: true,
logViewable: false,
virtualized: true,
removeClippedSubviews: false,
empty: false,
useFlatListItemComponent: false,
fadingEdgeLength: 0,
Expand Down Expand Up @@ -131,6 +133,7 @@ class FlatListExample extends React.PureComponent<Props, State> {
{renderSmallSwitchOption(this, 'empty')}
{renderSmallSwitchOption(this, 'debug')}
{renderSmallSwitchOption(this, 'useFlatListItemComponent')}
{renderSmallSwitchOption(this, 'removeClippedSubviews')}
{Platform.OS === 'android' && (
<View>
<TextInput
Expand Down Expand Up @@ -165,7 +168,8 @@ class FlatListExample extends React.PureComponent<Props, State> {
inverted={this.state.inverted}
key={
(this.state.horizontal ? 'h' : 'v') +
(this.state.fixedHeight ? 'f' : 'd')
(this.state.fixedHeight ? 'f' : 'd') +
(this.state.removeClippedSubviews ? 'r' : 's')
}
keyboardShouldPersistTaps="always"
keyboardDismissMode="on-drag"
Expand All @@ -180,6 +184,7 @@ class FlatListExample extends React.PureComponent<Props, State> {
refreshing={false}
contentContainerStyle={styles.list}
viewabilityConfig={VIEWABILITY_CONFIG}
removeClippedSubviews={this.state.removeClippedSubviews}
{...flatListItemRendererProps}
/>
</View>
Expand Down
6 changes: 6 additions & 0 deletions RNTester/js/examples/SectionList/SectionListExample.js
Original file line number Diff line number Diff line change
Expand Up @@ -77,13 +77,15 @@ class SectionListExample extends React.PureComponent<{...}, $FlowFixMeState> {
inverted: boolean,
logViewable: boolean,
virtualized: boolean,
removeClippedSubviews: boolean,
|} = {
data: genItemData(1000),
debug: false,
filterText: '',
logViewable: false,
virtualized: true,
inverted: false,
removeClippedSubviews: false,
};

_scrollPos = new Animated.Value(0);
Expand Down Expand Up @@ -134,6 +136,7 @@ class SectionListExample extends React.PureComponent<{...}, $FlowFixMeState> {
{renderSmallSwitchOption(this, 'logViewable')}
{renderSmallSwitchOption(this, 'debug')}
{renderSmallSwitchOption(this, 'inverted')}
{renderSmallSwitchOption(this, 'removeClippedSubviews')}
<Spindicator value={this._scrollPos} />
</View>
<View style={styles.scrollToRow}>
Expand Down Expand Up @@ -211,6 +214,8 @@ class SectionListExample extends React.PureComponent<{...}, $FlowFixMeState> {
]}
style={styles.list}
viewabilityConfig={VIEWABILITY_CONFIG}
removeClippedSubviews={this.state.removeClippedSubviews}
key={this.state.removeClippedSubviews ? 'r' : 's'}
/>
</RNTesterPage>
);
Expand Down Expand Up @@ -292,6 +297,7 @@ const styles = StyleSheet.create({

exports.title = '<SectionList>';
exports.description = 'Performant, scrollable list of data.';
exports.simpleExampleContainer = true;
exports.examples = [
{
title: 'Simple scrollable list',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -724,6 +724,10 @@ public void onStartTemporaryDetach() {
@Override
public void onAttachedToWindow() {
super.onAttachedToWindow();
// Used to ensure that text is selectable inside of removeClippedSubviews
// See https://github.com/facebook/react-native/issues/6805 for original
// fix that was ported to here.
super.setTextIsSelectable(true);
if (mContainsImages) {
Spanned text = getText();
TextInlineImageSpan[] spans = text.getSpans(0, text.length(), TextInlineImageSpan.class);
Expand Down