-
Notifications
You must be signed in to change notification settings - Fork 24.4k
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
[Android] Using TextInput inside ViewPagerAndroid causes context menu (copy/paste) in some cases to not display #20887
Comments
In some instances setting style properties such as height to an EditText inside a ViewPager will not allow the user to select text. Android logcat will instead display: "TextView does not support text selection. Selection cancelled." This seems to be an Android bug - https://code.google.com/p/android/issues/detail?id=208169 This workaround toggles the "enabled" state when the EditText is attached to the window to circumvent this bug. Fixes facebook#20887
Here's also a current hacky workaround tested for the current RN version without having to change native code. class InputField extends React.Component<Props, State> {
static defaultProps = {
editable: true,
}
constructor(props) {
super(props);
this.state = {
editable: !props.editable
};
}
componentDidMount() {
if (this.props.editable) {
setTimeout(() => {
this.setState({ editable: true });
}, 100);
}
}
render() {
const { editable } = this.state;
return <TextInput {...this.props} editable={editable} />;
}
} |
Updated Snack with minimal repro. Just perform a small edit, let the app hot reload and attempt to select text from the first text box. |
Hi, i have this issue too! Any updates or native workarounds? Also, reproducable example: https://snack.expo.io/S1A0eJ30X |
Looks like 0.58.0-rc.1 seems to solve this issue. There's about a thousand commits between the previous release so I'm not sure exactly what had fixed it. |
This is still an issue in 0.59.2 |
Still an issue in 0.59.3 |
Still an issue in 0.59.9, but at least the workaround does the job #20887 (comment) |
Should this not always update the state to the prop? So something like this
|
@jamsch why close this bug!!! |
still issue in RN 0.60.3 |
If you're using react-native-screens, the issue could be as referenced here: software-mansion/react-native-screens#40 (comment) |
@cpojer Could you please re-open this? |
Still an issue in RN 0.61.4 I used a 'hooks' version of the workaround:
|
Environment
Description
TextInput
inViewPagerAndroid
The following steps will not always reproduce the bug but in some configurations it can cause the effect. One of the apps I'm working on always has this bug however I am yet to find the exact reason why (perhaps due to a heavier component mount tree or subsequent component updates).
Another observation is that this is most prevalent if the device orientation is locked. When rotating to landscape and back to portrait, it seems to regain function. This may be due to
View.onMeasure(int, int)
and followingView.onAttachedToWindow()
being called on Native Android.Another observation is that resuming the app after being in the background for a while will cause this issue.
This has not been working for at least the last couple of RN versions. It does not work on 0.57.0-rc.3 either. Here's someone experiencing the same issue in 2016: link.
Reproducible Demo
https://snack.expo.io/SJurHkrvm
Note: Perform a small change in the snack and let the app hot reload. Text selection ability should be lost.
The text was updated successfully, but these errors were encountered: