react-native/Libraries/Text/TextInput
Emily Janzer 36507e4a3c Fix issue when inserting text at 0 when maxLength is set
Summary:
1. The user inserts a character ('0') at index 0. Because the range matches 0, 0, predictedText is set to that character that was inserted.
2. In textInputDidChange, it discovers a mismatch between the rendered text ('1234') and predicted text ('0')
3. This triggers textInputShouldChangeTextInRange to be called again with the 'new' text that it thinks was just added ('1234')
4. It goes to insert this text, but runs into the maxLength limit, so it gets truncated and then inserted.

(I'm not totally sure why only happens if maxLength is set - I need to look into that.)

One fix for this is to just get rid of the range check, but that'll regress #18374. I decided to just check and see if the rendered text is empty instead of checking the range where text could be inserted, since that seems like it should properly handle both cases.

Reviewed By: shergin

Differential Revision: D10392176

fbshipit-source-id: 84fb3b6cac9b0aa25b3c1a127d43f9cdc5a1c6a8
2018-10-16 19:44:28 -07:00
..
Multiline Update copyright headers to yearless format 2018-09-11 15:33:07 -07:00
Singleline Update copyright headers to yearless format 2018-09-11 15:33:07 -07:00
RCTBackedTextInputDelegate.h Update copyright headers to yearless format 2018-09-11 15:33:07 -07:00
RCTBackedTextInputDelegateAdapter.h Update copyright headers to yearless format 2018-09-11 15:33:07 -07:00
RCTBackedTextInputDelegateAdapter.m Update copyright headers to yearless format 2018-09-11 15:33:07 -07:00
RCTBackedTextInputViewProtocol.h Update copyright headers to yearless format 2018-09-11 15:33:07 -07:00
RCTBaseTextInputShadowView.h Update copyright headers to yearless format 2018-09-11 15:33:07 -07:00
RCTBaseTextInputShadowView.m Update copyright headers to yearless format 2018-09-11 15:33:07 -07:00
RCTBaseTextInputView.h Update copyright headers to yearless format 2018-09-11 15:33:07 -07:00
RCTBaseTextInputView.m Fix issue when inserting text at 0 when maxLength is set 2018-10-16 19:44:28 -07:00
RCTBaseTextInputViewManager.h Update copyright headers to yearless format 2018-09-11 15:33:07 -07:00
RCTBaseTextInputViewManager.m Update copyright headers to yearless format 2018-09-11 15:33:07 -07:00
RCTInputAccessoryShadowView.h Update copyright headers to yearless format 2018-09-11 15:33:07 -07:00
RCTInputAccessoryShadowView.m Update copyright headers to yearless format 2018-09-11 15:33:07 -07:00
RCTInputAccessoryView.h Update copyright headers to yearless format 2018-09-11 15:33:07 -07:00
RCTInputAccessoryView.m Fix InputAccessoryView safe area when not attached to a TextInput (#21179) 2018-09-18 18:31:51 -07:00
RCTInputAccessoryViewContent.h Update copyright headers to yearless format 2018-09-11 15:33:07 -07:00
RCTInputAccessoryViewContent.m Fix InputAccessoryView safe area when not attached to a TextInput (#21179) 2018-09-18 18:31:51 -07:00
RCTInputAccessoryViewManager.h Update copyright headers to yearless format 2018-09-11 15:33:07 -07:00
RCTInputAccessoryViewManager.m Update copyright headers to yearless format 2018-09-11 15:33:07 -07:00
RCTTextSelection.h Update copyright headers to yearless format 2018-09-11 15:33:07 -07:00
RCTTextSelection.m Update copyright headers to yearless format 2018-09-11 15:33:07 -07:00