[GH-ISSUE #287] TextInput Cursor keep reset to starting position when setState, #196

Open
opened 2026-05-05 11:54:20 -06:00 by gitea-mirror · 1 comment
Owner

Originally created by @Taymindis on GitHub (May 2, 2020).
Original GitHub issue: https://github.com/kusti8/proton-native/issues/287

Describe the bug
TextInput Cursor keep reseting to first position when setState on event of changeText,

To Reproduce

<View style={{ flex: 1, flexDirection: 'column' }}>
            <TextInput
              onBlur={() => {
                console.log('blur');
              }}
              onChangeText={text => {
                this.setState({ text });
              }}
              value={this.state.text}
              style={{ flex: 1 }}
              multiline
            />
          </View>

Expected behavior
It should be back to the position where it lay

Originally created by @Taymindis on GitHub (May 2, 2020). Original GitHub issue: https://github.com/kusti8/proton-native/issues/287 **Describe the bug** TextInput Cursor keep reseting to first position when setState on event of changeText, **To Reproduce** ```jsx <View style={{ flex: 1, flexDirection: 'column' }}> <TextInput onBlur={() => { console.log('blur'); }} onChangeText={text => { this.setState({ text }); }} value={this.state.text} style={{ flex: 1 }} multiline /> </View> ``` **Expected behavior** It should be back to the position where it lay
gitea-mirror added the
bug
label 2026-05-05 11:54:21 -06:00
Author
Owner

@HassanA14 commented on GitHub (Aug 12, 2024):

I had the same issue. All you have to do is remove value={this.state.text} from your <TextInput /> component. For example:

<View style={{ flex: 1, flexDirection: 'column' }}>
            <TextInput
              onBlur={() => {
                console.log('blur');
              }}
              onChangeText={text => {
                this.setState({ text });
              }}
              style={{ flex: 1 }}
              multiline
            />
          </View>
<!-- gh-comment-id:2284587206 --> @HassanA14 commented on GitHub (Aug 12, 2024): I had the same issue. All you have to do is remove `value={this.state.text}` from your `<TextInput />` component. For example: ```javascript <View style={{ flex: 1, flexDirection: 'column' }}> <TextInput onBlur={() => { console.log('blur'); }} onChangeText={text => { this.setState({ text }); }} style={{ flex: 1 }} multiline /> </View> ```
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference: github-starred/proton-native#196
No description provided.