KEMBAR78
[Android]TextInput selection order is different if backspace is pressed or any other key · Issue #25044 · facebook/react-native · GitHub
Skip to content

[Android]TextInput selection order is different if backspace is pressed or any other key #25044

@ahmed-hararaa

Description

@ahmed-hararaa

If subtext is selected then i press backspace then order of events is the following

onSelection {start: 3, end: 8}

onSelection {start: 8, end: 8}

onChange

onSelection {start: 3, end: 3}

and if i press anything else the order is the following

onSelection {start: 3, end: 8}

onChange

onSelection {start: 4, end: 4}

React Native version:

React Native Environment Info:
System:
OS: Windows 10
CPU: (4) x64 Intel(R) Core(TM) i5-2520M CPU @ 2.50GHz
Memory: 1.07 GB / 5.89 GB
Binaries:
Yarn: 1.13.0 - C:\Program Files (x86)\Yarn\bin\yarn.CMD
npm: 6.7.0 - C:\Program Files\nodejs\npm.CMD
IDEs:
Android Studio: Version 3.3.0.0 AI-182.5107.16.33.5314842

Steps To Reproduce

import React from 'react' import {TextInput, View} from 'react-native'

export default class Test extends React.Component {

state = {
    text: ''
}
handleSelectionChange = ({ nativeEvent: { selection } }) => {
    console.log("onSelection", selection)
}

onChange = ({text}) => {
    console.log("onChange")
    this.setState({
        text
    })
}
render () {
    const {text} = this.state
    return(
        <View style={{flex:1, justifyContent:'center'}}>
            <TextInput onSelectionChange={this.handleSelectionChange} style={{width:'100%'}} value={text} onChange={this.onChange}/>
        </View>
    )
}

}

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugComponent: TextInputRelated to the TextInput component.Platform: AndroidAndroid applications.StaleThere has been a lack of activity on this issue and it may be closed soon.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions