From b861782562080bf9c91afcac0f823d96088c2d8d Mon Sep 17 00:00:00 2001 From: Samuel Susla Date: Tue, 14 Apr 2020 15:25:04 -0700 Subject: [PATCH] Remove setMostRecentEventCount from TextInput view commands Summary: Changelog: [Internal] We don't use view command `setMostRecentEventCount`, let's get rid of it. Reviewed By: JoshuaGross Differential Revision: D21016600 fbshipit-source-id: 6491c063e9d6a89252300cb47c010b248e473f4b --- .../AndroidTextInputNativeComponent.js | 7 +----- .../RCTMultilineTextInputNativeComponent.js | 7 +----- .../RCTSingelineTextInputNativeComponent.js | 7 +----- .../TextInput/TextInputNativeCommands.js | 11 +--------- .../TextInput/RCTBaseTextInputViewManager.m | 8 ------- .../TextInput/RCTTextInputComponentView.mm | 5 ----- .../TextInput/RCTTextInputNativeCommands.h | 22 ------------------- .../textinput/ReactTextInputManager.java | 3 --- 8 files changed, 4 insertions(+), 66 deletions(-) diff --git a/Libraries/Components/TextInput/AndroidTextInputNativeComponent.js b/Libraries/Components/TextInput/AndroidTextInputNativeComponent.js index e8598a6bfc435b..2ac53e759b825d 100644 --- a/Libraries/Components/TextInput/AndroidTextInputNativeComponent.js +++ b/Libraries/Components/TextInput/AndroidTextInputNativeComponent.js @@ -544,12 +544,7 @@ type NativeType = HostComponent; type NativeCommands = TextInputNativeCommands; export const Commands: NativeCommands = codegenNativeCommands({ - supportedCommands: [ - 'focus', - 'blur', - 'setMostRecentEventCount', - 'setTextAndSelection', - ], + supportedCommands: ['focus', 'blur', 'setTextAndSelection'], }); let AndroidTextInputNativeComponent; diff --git a/Libraries/Components/TextInput/RCTMultilineTextInputNativeComponent.js b/Libraries/Components/TextInput/RCTMultilineTextInputNativeComponent.js index 950e5e1215c33f..a0dd8841123f6d 100644 --- a/Libraries/Components/TextInput/RCTMultilineTextInputNativeComponent.js +++ b/Libraries/Components/TextInput/RCTMultilineTextInputNativeComponent.js @@ -22,12 +22,7 @@ type NativeType = HostComponent; type NativeCommands = TextInputNativeCommands; export const Commands: NativeCommands = codegenNativeCommands({ - supportedCommands: [ - 'focus', - 'blur', - 'setMostRecentEventCount', - 'setTextAndSelection', - ], + supportedCommands: ['focus', 'blur', 'setTextAndSelection'], }); const SinglelineTextInputNativeComponent: HostComponent = requireNativeComponent( diff --git a/Libraries/Components/TextInput/RCTSingelineTextInputNativeComponent.js b/Libraries/Components/TextInput/RCTSingelineTextInputNativeComponent.js index 78fcf530262f32..8a6f85756a6af6 100644 --- a/Libraries/Components/TextInput/RCTSingelineTextInputNativeComponent.js +++ b/Libraries/Components/TextInput/RCTSingelineTextInputNativeComponent.js @@ -24,12 +24,7 @@ type NativeType = HostComponent; type NativeCommands = TextInputNativeCommands; export const Commands: NativeCommands = codegenNativeCommands({ - supportedCommands: [ - 'focus', - 'blur', - 'setMostRecentEventCount', - 'setTextAndSelection', - ], + supportedCommands: ['focus', 'blur', 'setTextAndSelection'], }); let SinglelineTextInputNativeComponent; diff --git a/Libraries/Components/TextInput/TextInputNativeCommands.js b/Libraries/Components/TextInput/TextInputNativeCommands.js index d669b09f9d152b..2584b7516c804b 100644 --- a/Libraries/Components/TextInput/TextInputNativeCommands.js +++ b/Libraries/Components/TextInput/TextInputNativeCommands.js @@ -17,10 +17,6 @@ import type {Int32} from '../../Types/CodegenTypes'; export interface TextInputNativeCommands { +focus: (viewRef: React.ElementRef) => void; +blur: (viewRef: React.ElementRef) => void; - +setMostRecentEventCount: ( - viewRef: React.ElementRef, - eventCount: Int32, - ) => void; +setTextAndSelection: ( viewRef: React.ElementRef, mostRecentEventCount: Int32, @@ -30,11 +26,6 @@ export interface TextInputNativeCommands { ) => void; } -const supportedCommands = [ - 'focus', - 'blur', - 'setMostRecentEventCount', - 'setTextAndSelection', -]; +const supportedCommands = ['focus', 'blur', 'setTextAndSelection']; export default supportedCommands; diff --git a/Libraries/Text/TextInput/RCTBaseTextInputViewManager.m b/Libraries/Text/TextInput/RCTBaseTextInputViewManager.m index 695d0f6c8fe6b3..d0626ee1f4b1bd 100644 --- a/Libraries/Text/TextInput/RCTBaseTextInputViewManager.m +++ b/Libraries/Text/TextInput/RCTBaseTextInputViewManager.m @@ -117,14 +117,6 @@ - (void)setBridge:(RCTBridge *)bridge }]; } -RCT_EXPORT_METHOD(setMostRecentEventCount : (nonnull NSNumber *)viewTag eventCount:(NSInteger)eventCount) -{ - [self.bridge.uiManager addUIBlock:^(RCTUIManager *uiManager, NSDictionary *viewRegistry) { - RCTBaseTextInputView *view = (RCTBaseTextInputView *)viewRegistry[viewTag]; - view.mostRecentEventCount = eventCount; - }]; -} - RCT_EXPORT_METHOD(setTextAndSelection : (nonnull NSNumber *)viewTag mostRecentEventCount : (NSInteger)mostRecentEventCount value : (NSString *)value diff --git a/React/Fabric/Mounting/ComponentViews/TextInput/RCTTextInputComponentView.mm b/React/Fabric/Mounting/ComponentViews/TextInput/RCTTextInputComponentView.mm index 094be116826713..aa1f4a4ae6a66b 100644 --- a/React/Fabric/Mounting/ComponentViews/TextInput/RCTTextInputComponentView.mm +++ b/React/Fabric/Mounting/ComponentViews/TextInput/RCTTextInputComponentView.mm @@ -404,11 +404,6 @@ - (void)blur [_backedTextInputView resignFirstResponder]; } -- (void)setMostRecentEventCount:(NSInteger)eventCount -{ - _mostRecentEventCount = eventCount; -} - - (void)setTextAndSelection:(NSInteger)eventCount value:(NSString *__nullable)value start:(NSInteger)start diff --git a/React/Fabric/Mounting/ComponentViews/TextInput/RCTTextInputNativeCommands.h b/React/Fabric/Mounting/ComponentViews/TextInput/RCTTextInputNativeCommands.h index db72f239f09435..6af78ddf7e1872 100644 --- a/React/Fabric/Mounting/ComponentViews/TextInput/RCTTextInputNativeCommands.h +++ b/React/Fabric/Mounting/ComponentViews/TextInput/RCTTextInputNativeCommands.h @@ -14,7 +14,6 @@ NS_ASSUME_NONNULL_BEGIN @protocol RCTTextInputViewProtocol - (void)focus; - (void)blur; -- (void)setMostRecentEventCount:(NSInteger)eventCount; - (void)setTextAndSelection:(NSInteger)eventCount value:(NSString *__nullable)value start:(NSInteger)start @@ -50,27 +49,6 @@ RCTTextInputHandleCommand(id componentView, NSString c return; } - if ([commandName isEqualToString:@"setMostRecentEventCount"]) { -#if RCT_DEBUG - if ([args count] != 1) { - RCTLogError( - @"%@ command %@ received %d arguments, expected %d.", @"TextInput", commandName, (int)[args count], 1); - return; - } -#endif - - NSObject *arg0 = args[0]; -#if RCT_DEBUG - if (!RCTValidateTypeOfViewCommandArgument(arg0, [NSNumber class], @"number", @"TextInput", commandName, @"1st")) { - return; - } -#endif - NSInteger eventCount = [(NSNumber *)arg0 intValue]; - - [componentView setMostRecentEventCount:eventCount]; - return; - } - if ([commandName isEqualToString:@"setTextAndSelection"]) { #if RCT_DEBUG if ([args count] != 4) { diff --git a/ReactAndroid/src/main/java/com/facebook/react/views/textinput/ReactTextInputManager.java b/ReactAndroid/src/main/java/com/facebook/react/views/textinput/ReactTextInputManager.java index 74c4a2ad7db6e9..4bbbca329733de 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/views/textinput/ReactTextInputManager.java +++ b/ReactAndroid/src/main/java/com/facebook/react/views/textinput/ReactTextInputManager.java @@ -230,9 +230,6 @@ public void receiveCommand( case "blurTextInput": reactEditText.clearFocusFromJS(); break; - case "setMostRecentEventCount": - // TODO: delete, this is no longer used from JS - break; case "setTextAndSelection": int mostRecentEventCount = args.getInt(0); if (mostRecentEventCount == UNSET) {