From 0c9c57a9f73294414d92428c5d2472dc1e1e5e96 Mon Sep 17 00:00:00 2001 From: Koichi Nagaoka Date: Tue, 4 Jul 2023 06:25:22 -0700 Subject: [PATCH] Fix onChangeText not firing when clearing the value of TextInput with multiline=true on iOS (#37958) Summary: This fix fixes the TextInput issue in https://github.com/facebook/react-native/issues/37784 with onChangeText not working on iOS only. ## Changelog: [IOS] [FIXED] - Fix onChangeText not firing when clearing the value of TextInput with multiline=true on iOS Pull Request resolved: https://github.com/facebook/react-native/pull/37958 Test Plan: 1. Run the repro code given in the issue (https://github.com/facebook/react-native/issues/37784). 2. Verified that onChangeText works after pressing the submit button. 3. Run the repro code from the issue (https://github.com/facebook/react-native/issues/36494) that caused this issue. 4. Verified that issue (https://github.com/facebook/react-native/issues/36494) is not reoccurring. Reviewed By: rshest Differential Revision: D47185775 Pulled By: dmytrorykun fbshipit-source-id: 1a1a6534d6bf8b5bb8cf1090734dd894bab43f82 --- .../Text/TextInput/RCTBackedTextInputDelegateAdapter.m | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/react-native/Libraries/Text/TextInput/RCTBackedTextInputDelegateAdapter.m b/packages/react-native/Libraries/Text/TextInput/RCTBackedTextInputDelegateAdapter.m index 1c8f8e055e8399..9dca6a5567d9a0 100644 --- a/packages/react-native/Libraries/Text/TextInput/RCTBackedTextInputDelegateAdapter.m +++ b/packages/react-native/Libraries/Text/TextInput/RCTBackedTextInputDelegateAdapter.m @@ -256,7 +256,7 @@ - (BOOL)textView:(__unused UITextView *)textView shouldChangeTextInRange:(NSRang - (void)textViewDidChange:(__unused UITextView *)textView { - if (_ignoreNextTextInputCall) { + if (_ignoreNextTextInputCall && [_lastStringStateWasUpdatedWith isEqual:_backedTextInputView.attributedText]) { _ignoreNextTextInputCall = NO; return; }