mirror of
https://github.com/zhigang1992/react-native.git
synced 2026-04-23 20:01:01 +08:00
TextInput: Fixed autoscroll to cursor on Android
Summary: This feature was disabled for multiline textinputs in D3528202 ... seems without a good reason. The broken autoscroll-to-cursor feature is terribly harmful and counter-intuitive in ALL cases. I also add a contentSize tracking in the example app to make sure that it is unaffected by this change. https://pxl.cl/9RHP https://github.com/facebook/react-native/issues/12799 https://github.com/facebook/react-native/issues/15778 Special thanks to konradkierus! Reviewed By: sahrens Differential Revision: D6405985 fbshipit-source-id: 337a390a9db7b3528200ef66c4a079b87608294e
This commit is contained in:
committed by
Facebook Github Bot
parent
a7d46ea970
commit
0bef872f3f
@@ -320,10 +320,14 @@ class AutogrowingTextInputExample extends React.Component<{}> {
|
||||
width: 100,
|
||||
multiline: true,
|
||||
text: '',
|
||||
contentSize: {
|
||||
width: 0,
|
||||
height: 0,
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
componentDidReceiveProps(props) {
|
||||
componentWillReceiveProps(props) {
|
||||
this.setState({
|
||||
multiline: props.multiline,
|
||||
});
|
||||
@@ -351,10 +355,12 @@ class AutogrowingTextInputExample extends React.Component<{}> {
|
||||
multiline={this.state.multiline}
|
||||
style={[style, {width: this.state.width + '%'}]}
|
||||
onChangeText={(value) => this.setState({text: value})}
|
||||
onContentSizeChange={(event) => this.setState({contentSize: event.nativeEvent.contentSize})}
|
||||
{...props}
|
||||
/>
|
||||
<Text>Plain text value representation:</Text>
|
||||
<Text>{this.state.text}</Text>
|
||||
<Text>Content Size: {JSON.stringify(this.state.contentSize)}</Text>
|
||||
</View>
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user