{"action":"opened","issue":{"url":"https://api.github.com/repos/facebook/react-native/issues/21515","repository_url":"https://api.github.com/repos/facebook/react-native","labels_url":"https://api.github.com/repos/facebook/react-native/issues/21515/labels{/name}","comments_url":"https://api.github.com/repos/facebook/react-native/issues/21515/comments","events_url":"https://api.github.com/repos/facebook/react-native/issues/21515/events","html_url":"https://github.com/facebook/react-native/issues/21515","id":367247889,"node_id":"MDU6SXNzdWUzNjcyNDc4ODk=","number":21515,"title":"onSelectionChange does not work properly in TextInput single line mode","user":{"login":"liamse","id":3607101,"node_id":"MDQ6VXNlcjM2MDcxMDE=","avatar_url":"https://avatars0.githubusercontent.com/u/3607101?v=4","gravatar_id":"","url":"https://api.github.com/users/liamse","html_url":"https://github.com/liamse","followers_url":"https://api.github.com/users/liamse/followers","following_url":"https://api.github.com/users/liamse/following{/other_user}","gists_url":"https://api.github.com/users/liamse/gists{/gist_id}","starred_url":"https://api.github.com/users/liamse/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/liamse/subscriptions","organizations_url":"https://api.github.com/users/liamse/orgs","repos_url":"https://api.github.com/users/liamse/repos","events_url":"https://api.github.com/users/liamse/events{/privacy}","received_events_url":"https://api.github.com/users/liamse/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2018-10-05T14:57:32Z","updated_at":"2018-10-05T14:57:32Z","closed_at":null,"author_association":"NONE","body":"## Environment\r\nNode: 8.11.1 - /usr/local/bin/node\r\n      Yarn: 1.5.1 - /usr/local/bin/yarn\r\n      npm: 6.4.0 - /usr/local/bin/npm\r\n    SDKs:\r\n      iOS SDK:\r\n        Platforms: iOS 11.4, macOS 10.13, tvOS 11.4, watchOS 4.3\r\n    IDEs:\r\n      Xcode: 9.4/9F1027a - /usr/bin/xcodebuild\r\n    npmPackages:\r\n      react: 16.5.0 => 16.5.0\r\n      react-native: 0.57.1 => 0.57.1\r\n\r\n## Description\r\n`onSelectionChange` method of `TextInput` does not return proper value when you use TextInput in single mode (not set `multiline = {true}`).\r\n\r\n## Reproducible Demo\r\n\r\n```js\r\n// App.js\r\nimport React, {Component} from 'react';\r\nimport {Platform, StyleSheet, Text, View, TextInput} from 'react-native';\r\n\r\ntype Props = {};\r\nexport default class App extends Component<Props> {\r\n\r\n  constructor(props) {\r\n    super(props)\r\n    this.state = {\r\n      selection: {start: 0, end: 0},\r\n      text: 'This is a sample text',\r\n    }\r\n  }\r\n  render() {\r\n    return (\r\n        <View style={styles.container}>\r\n          <Text>{this.state.selection.start}, {this.state.selection.end}</Text>\r\n          <TextInput\r\n            style={{ width: 300, borderColor: 'gray', borderWidth: 1 }}\r\n            onSelectionChange={({ nativeEvent: { selection } }) => {\r\n              this.setState({ selection })\r\n            }}\r\n            onChangeText={(text) => this.setState({ text })}\r\n            value={this.state.text}\r\n          />\r\n        </View>\r\n    );\r\n  }\r\n}\r\n```\r\n\r\nRun the code, if you select the part of text in TextInput, you need to see the number of start and end of selection, but you don't see anything unless you start to type, or cut the selected part, if the text is change the selection numbers appear. \r\n\r\nAfter select the part of text, the result is like following image: \r\n![screen shot 2018-10-05 at 6 22 26 pm](https://user-images.githubusercontent.com/3607101/46542642-c68f5a80-c8cb-11e8-9156-67a793ffb4e8.png)\r\n\r\nBut if you add `multiline = {true}` it works properly.\r\n![screen shot 2018-10-05 at 6 25 37 pm](https://user-images.githubusercontent.com/3607101/46542796-2e45a580-c8cc-11e8-8a69-c6188dcaac62.png)\r\n\r\n"}}
{"actor":{"display_login":"liamse"}}