Skip to content

Commit

Permalink
textinput: Maintain cursor position when secureTextEntry toggles.
Browse files Browse the repository at this point in the history
Summary:
<!--
Thank you for sending the PR! We appreciate you spending the time to work on these changes.

Help us understand your motivation by explaining why you decided to make this change.

You can learn more about contributing to React Native here: http://facebook.github.io/react-native/docs/contributing.html

Happy contributing!

-->

On current [master](https://github.com/facebook/react-native/tree/8235a49a33cc8e84cd4ba1cc15bc09eed6712b4c), text input cursor resets to start when `secureTextEntry` prop toggles on Android. This motivate me to maintain position when `secureTextEntry ` prop toggles for better user experience.

On current [master](https://github.com/facebook/react-native/tree/8235a49a33cc8e84cd4ba1cc15bc09eed6712b4c)
![ezgif com-video-to-gif-3](https://user-images.githubusercontent.com/18511177/35776882-bdc3b182-09ca-11e8-8f4e-218fae0a24a1.gif)

On this PR
![ezgif com-video-to-gif-4](https://user-images.githubusercontent.com/18511177/35776883-be082d94-09ca-11e8-9424-6164110bdf03.gif)

[ANDROID] [BUGFIX] [TextInput] - Fix: cursor positions resets to start on toggling `secureTextEntry` prop.

<!--
Help reviewers and the release process by writing your own release notes

**INTERNAL and MINOR tagged notes will not be included in the next version's final release notes.**

  CATEGORY
[----------]        TYPE
[ CLI      ]   [-------------]      LOCATION
[ DOCS     ]   [ BREAKING    ]   [-------------]
[ GENERAL  ]   [ BUGFIX      ]   [-{Component}-]
[ INTERNAL ]   [ ENHANCEMENT ]   [ {File}      ]
[ IOS      ]   [ FEATURE     ]   [ {Directory} ]   |-----------|
[ ANDROID  ]   [ MINOR       ]   [ {Framework} ] - | {Message} |
[----------]   [-------------]   [-------------]   |-----------|

[CATEGORY] [TYPE] [LOCATION] - MESSAGE

 EXAMPLES:

 [IOS] [BREAKING] [FlatList] - Change a thing that breaks other things
 [ANDROID] [BUGFIX] [TextInput] - Did a thing to TextInput
 [CLI] [FEATURE] [local-cli/info/info.js] - CLI easier to do things with
 [DOCS] [BUGFIX] [GettingStarted.md] - Accidentally a thing/word
 [GENERAL] [ENHANCEMENT] [Yoga] - Added new yoga thing/position
 [INTERNAL] [FEATURE] [./scripts] - Added thing to script that nobody will see
-->
Closes #17851

Differential Revision: D6925711

Pulled By: hramos

fbshipit-source-id: 6d53ad2dbed2dca20cd21e5b1b0578be13a91aad
  • Loading branch information
jainkuniya authored and facebook-github-bot committed Feb 7, 2018
1 parent 9e6f3b8 commit 09b43e4
Showing 1 changed file with 3 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -309,7 +309,10 @@ public String getReturnKeyType() {

/*package*/ void commitStagedInputType() {
if (getInputType() != mStagedInputType) {
int selectionStart = getSelectionStart();
int selectionEnd = getSelectionEnd();
setInputType(mStagedInputType);
setSelection(selectionStart, selectionEnd);
}
}

Expand Down

0 comments on commit 09b43e4

Please sign in to comment.