Skip to content

Commit

Permalink
Merge pull request #54957 from callstack-internal/fix/50057-disable-s…
Browse files Browse the repository at this point in the history
…uggestion-pop-up-patch

Add a new patch to temporary disable suggestion pop up
  • Loading branch information
AndrewGable authored Jan 16, 2025
2 parents a2e0558 + 4c60c0f commit 46a5887
Show file tree
Hide file tree
Showing 2 changed files with 326 additions and 0 deletions.
325 changes: 325 additions & 0 deletions patches/react-native+0.76.3+030+disable-suggestion-pop-up.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,325 @@
diff --git a/node_modules/react-native/Libraries/Components/TextInput/RCTTextInputViewConfig.js b/node_modules/react-native/Libraries/Components/TextInput/RCTTextInputViewConfig.js
index 0973ae8..d5e6cee 100644
--- a/node_modules/react-native/Libraries/Components/TextInput/RCTTextInputViewConfig.js
+++ b/node_modules/react-native/Libraries/Components/TextInput/RCTTextInputViewConfig.js
@@ -169,6 +169,7 @@ const RCTTextInputViewConfig = {
onChangeSync: true,
onKeyPressSync: true,
}),
+ disableKeyboardShortcuts: true,
},
};

diff --git a/node_modules/react-native/Libraries/Components/TextInput/TextInput.d.ts b/node_modules/react-native/Libraries/Components/TextInput/TextInput.d.ts
index 47cdcfc..22c42ae 100644
--- a/node_modules/react-native/Libraries/Components/TextInput/TextInput.d.ts
+++ b/node_modules/react-native/Libraries/Components/TextInput/TextInput.d.ts
@@ -136,6 +136,11 @@ export interface DocumentSelectionState extends EventEmitter {
* @see https://reactnative.dev/docs/textinput#props
*/
export interface TextInputIOSProps {
+ /**
+ * If true, the keyboard shortcuts (undo/redo and copy buttons) are disabled. The default value is false.
+ */
+ disableKeyboardShortcuts?: boolean | undefined;
+
/**
* enum('never', 'while-editing', 'unless-editing', 'always')
* When the clear button should appear on the right side of the text view
diff --git a/node_modules/react-native/Libraries/Components/TextInput/TextInput.flow.js b/node_modules/react-native/Libraries/Components/TextInput/TextInput.flow.js
index 2f35731..a1455e7 100644
--- a/node_modules/react-native/Libraries/Components/TextInput/TextInput.flow.js
+++ b/node_modules/react-native/Libraries/Components/TextInput/TextInput.flow.js
@@ -224,6 +224,12 @@ export type enterKeyHintType =
type PasswordRules = string;

type IOSProps = $ReadOnly<{|
+ /**
+ * If true, the keyboard shortcuts (undo/redo and copy buttons) are disabled. The default value is false.
+ * @platform ios
+ */
+ disableKeyboardShortcuts?: ?boolean,
+
/**
* When the clear button should appear on the right side of the text view.
* This property is supported only for single-line TextInput component.
diff --git a/node_modules/react-native/Libraries/Components/TextInput/TextInput.js b/node_modules/react-native/Libraries/Components/TextInput/TextInput.js
index 2ffb38b..40e732f 100644
--- a/node_modules/react-native/Libraries/Components/TextInput/TextInput.js
+++ b/node_modules/react-native/Libraries/Components/TextInput/TextInput.js
@@ -267,6 +267,12 @@ export type enterKeyHintType =
type PasswordRules = string;

type IOSProps = $ReadOnly<{|
+ /**
+ * If true, the keyboard shortcuts (undo/redo and copy buttons) are disabled. The default value is false.
+ * @platform ios
+ */
+ disableKeyboardShortcuts?: ?boolean,
+
/**
* When the clear button should appear on the right side of the text view.
* This property is supported only for single-line TextInput component.
diff --git a/node_modules/react-native/Libraries/Text/TextInput/Multiline/RCTUITextView.h b/node_modules/react-native/Libraries/Text/TextInput/Multiline/RCTUITextView.h
index 205f994..3b528d2 100644
--- a/node_modules/react-native/Libraries/Text/TextInput/Multiline/RCTUITextView.h
+++ b/node_modules/react-native/Libraries/Text/TextInput/Multiline/RCTUITextView.h
@@ -38,6 +38,8 @@ NS_ASSUME_NONNULL_BEGIN

@property (nonatomic, strong, nullable) NSString *inputAccessoryViewID;

+@property (nonatomic, assign) BOOL disableKeyboardShortcuts;
+
@end

NS_ASSUME_NONNULL_END
diff --git a/node_modules/react-native/Libraries/Text/TextInput/Multiline/RCTUITextView.mm b/node_modules/react-native/Libraries/Text/TextInput/Multiline/RCTUITextView.mm
index 065a819..b521dd9 100644
--- a/node_modules/react-native/Libraries/Text/TextInput/Multiline/RCTUITextView.mm
+++ b/node_modules/react-native/Libraries/Text/TextInput/Multiline/RCTUITextView.mm
@@ -22,6 +22,8 @@ @implementation RCTUITextView {
UITextView *_detachedTextView;
RCTBackedTextViewDelegateAdapter *_textInputDelegateAdapter;
NSDictionary<NSAttributedStringKey, id> *_defaultTextAttributes;
+ NSArray<UIBarButtonItemGroup *> *_initialValueLeadingBarButtonGroups;
+ NSArray<UIBarButtonItemGroup *> *_initialValueTrailingBarButtonGroups;
}

static UIFont *defaultPlaceholderFont(void)
@@ -56,6 +58,8 @@ - (instancetype)initWithFrame:(CGRect)frame
self.textContainer.lineFragmentPadding = 0;
self.scrollsToTop = NO;
self.scrollEnabled = YES;
+ _initialValueLeadingBarButtonGroups = nil;
+ _initialValueTrailingBarButtonGroups = nil;
}

return self;
@@ -136,6 +140,25 @@ - (void)textDidChange
[self _invalidatePlaceholderVisibility];
}

+- (void)setDisableKeyboardShortcuts:(BOOL)disableKeyboardShortcuts
+{
+ // Initialize the initial values only once
+ if (_initialValueLeadingBarButtonGroups == nil) {
+ // Capture initial values of leading and trailing button groups
+ _initialValueLeadingBarButtonGroups = self.inputAssistantItem.leadingBarButtonGroups;
+ _initialValueTrailingBarButtonGroups = self.inputAssistantItem.trailingBarButtonGroups;
+ }
+
+ if (disableKeyboardShortcuts) {
+ self.inputAssistantItem.leadingBarButtonGroups = @[];
+ self.inputAssistantItem.trailingBarButtonGroups = @[];
+ } else {
+ // Restore the initial values
+ self.inputAssistantItem.leadingBarButtonGroups = _initialValueLeadingBarButtonGroups;
+ self.inputAssistantItem.trailingBarButtonGroups = _initialValueTrailingBarButtonGroups;
+ }
+}
+
#pragma mark - Overrides

- (void)setFont:(UIFont *)font
diff --git a/node_modules/react-native/Libraries/Text/TextInput/RCTBackedTextInputViewProtocol.h b/node_modules/react-native/Libraries/Text/TextInput/RCTBackedTextInputViewProtocol.h
index cc51013..26a112f 100644
--- a/node_modules/react-native/Libraries/Text/TextInput/RCTBackedTextInputViewProtocol.h
+++ b/node_modules/react-native/Libraries/Text/TextInput/RCTBackedTextInputViewProtocol.h
@@ -51,6 +51,8 @@ NS_ASSUME_NONNULL_BEGIN
// Use `attributedText.string` instead.
@property (nonatomic, copy, nullable) NSString *text NS_UNAVAILABLE;

+@property (nonatomic, assign) BOOL disableKeyboardShortcuts;
+
@end

NS_ASSUME_NONNULL_END
diff --git a/node_modules/react-native/Libraries/Text/TextInput/RCTBaseTextInputView.mm b/node_modules/react-native/Libraries/Text/TextInput/RCTBaseTextInputView.mm
index 6047486..5d1e97b 100644
--- a/node_modules/react-native/Libraries/Text/TextInput/RCTBaseTextInputView.mm
+++ b/node_modules/react-native/Libraries/Text/TextInput/RCTBaseTextInputView.mm
@@ -30,6 +30,8 @@ @implementation RCTBaseTextInputView {
BOOL _hasInputAccessoryView;
NSString *_Nullable _predictedText;
BOOL _didMoveToWindow;
+ NSArray<UIBarButtonItemGroup *> *_initialValueLeadingBarButtonGroups;
+ NSArray<UIBarButtonItemGroup *> *_initialValueTrailingBarButtonGroups;
}

- (void)reactUpdateResponderOffsetForScrollView:(RCTScrollView *)scrollView
@@ -64,6 +66,8 @@ - (instancetype)initWithBridge:(RCTBridge *)bridge
_bridge = bridge;
_eventDispatcher = bridge.eventDispatcher;
[self initializeReturnKeyType];
+ _initialValueLeadingBarButtonGroups = nil;
+ _initialValueTrailingBarButtonGroups = nil;
}

return self;
@@ -374,6 +378,25 @@ - (void)setShowSoftInputOnFocus:(BOOL)showSoftInputOnFocus
}
}

+- (void)setDisableKeyboardShortcuts:(BOOL)disableKeyboardShortcuts
+{
+ // Initialize the initial values only once
+ if (_initialValueLeadingBarButtonGroups == nil) {
+ // Capture initial values of leading and trailing button groups
+ _initialValueLeadingBarButtonGroups = self.backedTextInputView.inputAssistantItem.leadingBarButtonGroups;
+ _initialValueTrailingBarButtonGroups = self.backedTextInputView.inputAssistantItem.trailingBarButtonGroups;
+ }
+
+ if (disableKeyboardShortcuts) {
+ self.backedTextInputView.inputAssistantItem.leadingBarButtonGroups = @[];
+ self.backedTextInputView.inputAssistantItem.trailingBarButtonGroups = @[];
+ } else {
+ // Restore the initial values
+ self.backedTextInputView.inputAssistantItem.leadingBarButtonGroups = _initialValueLeadingBarButtonGroups;
+ self.backedTextInputView.inputAssistantItem.trailingBarButtonGroups = _initialValueTrailingBarButtonGroups;
+ }
+}
+
#pragma mark - RCTBackedTextInputDelegate

- (BOOL)textInputShouldBeginEditing
diff --git a/node_modules/react-native/Libraries/Text/TextInput/RCTBaseTextInputViewManager.mm b/node_modules/react-native/Libraries/Text/TextInput/RCTBaseTextInputViewManager.mm
index e367394..08ec761 100644
--- a/node_modules/react-native/Libraries/Text/TextInput/RCTBaseTextInputViewManager.mm
+++ b/node_modules/react-native/Libraries/Text/TextInput/RCTBaseTextInputViewManager.mm
@@ -70,6 +70,8 @@ @implementation RCTBaseTextInputViewManager {

RCT_EXPORT_VIEW_PROPERTY(mostRecentEventCount, NSInteger)

+RCT_EXPORT_VIEW_PROPERTY(disableKeyboardShortcuts, BOOL)
+
RCT_EXPORT_SHADOW_PROPERTY(text, NSString)
RCT_EXPORT_SHADOW_PROPERTY(placeholder, NSString)
RCT_EXPORT_SHADOW_PROPERTY(onContentSizeChange, RCTDirectEventBlock)
diff --git a/node_modules/react-native/Libraries/Text/TextInput/Singleline/RCTUITextField.h b/node_modules/react-native/Libraries/Text/TextInput/Singleline/RCTUITextField.h
index 91f8eb0..fbf9f32 100644
--- a/node_modules/react-native/Libraries/Text/TextInput/Singleline/RCTUITextField.h
+++ b/node_modules/react-native/Libraries/Text/TextInput/Singleline/RCTUITextField.h
@@ -33,6 +33,7 @@ NS_ASSUME_NONNULL_BEGIN
@property (nonatomic, assign, readonly) CGFloat zoomScale;
@property (nonatomic, assign, readonly) CGPoint contentOffset;
@property (nonatomic, assign, readonly) UIEdgeInsets contentInset;
+@property (nonatomic, assign) BOOL disableKeyboardShortcuts;

@end

diff --git a/node_modules/react-native/Libraries/Text/TextInput/Singleline/RCTUITextField.mm b/node_modules/react-native/Libraries/Text/TextInput/Singleline/RCTUITextField.mm
index 667e646..617f05f 100644
--- a/node_modules/react-native/Libraries/Text/TextInput/Singleline/RCTUITextField.mm
+++ b/node_modules/react-native/Libraries/Text/TextInput/Singleline/RCTUITextField.mm
@@ -19,6 +19,8 @@
@implementation RCTUITextField {
RCTBackedTextFieldDelegateAdapter *_textInputDelegateAdapter;
NSDictionary<NSAttributedStringKey, id> *_defaultTextAttributes;
+ NSArray<UIBarButtonItemGroup *> *_initialValueLeadingBarButtonGroups;
+ NSArray<UIBarButtonItemGroup *> *_initialValueTrailingBarButtonGroups;
}

- (instancetype)initWithFrame:(CGRect)frame
@@ -31,6 +33,8 @@ - (instancetype)initWithFrame:(CGRect)frame

_textInputDelegateAdapter = [[RCTBackedTextFieldDelegateAdapter alloc] initWithTextField:self];
_scrollEnabled = YES;
+ _initialValueLeadingBarButtonGroups = nil;
+ _initialValueTrailingBarButtonGroups = nil;
}

return self;
@@ -119,6 +123,25 @@ - (void)setSecureTextEntry:(BOOL)secureTextEntry
self.attributedText = originalText;
}

+- (void)setDisableKeyboardShortcuts:(BOOL)disableKeyboardShortcuts
+{
+ // Initialize the initial values only once
+ if (_initialValueLeadingBarButtonGroups == nil) {
+ // Capture initial values of leading and trailing button groups
+ _initialValueLeadingBarButtonGroups = self.inputAssistantItem.leadingBarButtonGroups;
+ _initialValueTrailingBarButtonGroups = self.inputAssistantItem.trailingBarButtonGroups;
+ }
+
+ if (disableKeyboardShortcuts) {
+ self.inputAssistantItem.leadingBarButtonGroups = @[];
+ self.inputAssistantItem.trailingBarButtonGroups = @[];
+ } else {
+ // Restore the initial values
+ self.inputAssistantItem.leadingBarButtonGroups = _initialValueLeadingBarButtonGroups;
+ self.inputAssistantItem.trailingBarButtonGroups = _initialValueTrailingBarButtonGroups;
+ }
+}
+
#pragma mark - Placeholder

- (NSDictionary<NSAttributedStringKey, id> *)_placeholderTextAttributes
diff --git a/node_modules/react-native/React/Fabric/Mounting/ComponentViews/TextInput/RCTTextInputComponentView.mm b/node_modules/react-native/React/Fabric/Mounting/ComponentViews/TextInput/RCTTextInputComponentView.mm
index 2e7b1a1..abd91ef 100644
--- a/node_modules/react-native/React/Fabric/Mounting/ComponentViews/TextInput/RCTTextInputComponentView.mm
+++ b/node_modules/react-native/React/Fabric/Mounting/ComponentViews/TextInput/RCTTextInputComponentView.mm
@@ -278,6 +278,11 @@ - (void)updateProps:(const Props::Shared &)props oldProps:(const Props::Shared &
if (newTextInputProps.inputAccessoryViewID != oldTextInputProps.inputAccessoryViewID) {
_backedTextInputView.inputAccessoryViewID = RCTNSStringFromString(newTextInputProps.inputAccessoryViewID);
}
+
+ if (newTextInputProps.disableKeyboardShortcuts != oldTextInputProps.disableKeyboardShortcuts) {
+ _backedTextInputView.disableKeyboardShortcuts = newTextInputProps.disableKeyboardShortcuts;
+ }
+
[super updateProps:props oldProps:oldProps];

[self setDefaultInputAccessoryView];
diff --git a/node_modules/react-native/React/Fabric/Mounting/ComponentViews/TextInput/RCTTextInputUtils.mm b/node_modules/react-native/React/Fabric/Mounting/ComponentViews/TextInput/RCTTextInputUtils.mm
index 6345758..92c56b4 100644
--- a/node_modules/react-native/React/Fabric/Mounting/ComponentViews/TextInput/RCTTextInputUtils.mm
+++ b/node_modules/react-native/React/Fabric/Mounting/ComponentViews/TextInput/RCTTextInputUtils.mm
@@ -45,6 +45,7 @@ void RCTCopyBackedTextInput(
toTextInput.textContentType = fromTextInput.textContentType;
toTextInput.smartInsertDeleteType = fromTextInput.smartInsertDeleteType;
toTextInput.passwordRules = fromTextInput.passwordRules;
+ toTextInput.disableKeyboardShortcuts = fromTextInput.disableKeyboardShortcuts;

[toTextInput setSelectedTextRange:fromTextInput.selectedTextRange notifyDelegate:NO];
}
diff --git a/node_modules/react-native/ReactCommon/react/renderer/components/textinput/BaseTextInputProps.cpp b/node_modules/react-native/ReactCommon/react/renderer/components/textinput/BaseTextInputProps.cpp
index ec0f350..56c3b4f 100644
--- a/node_modules/react-native/ReactCommon/react/renderer/components/textinput/BaseTextInputProps.cpp
+++ b/node_modules/react-native/ReactCommon/react/renderer/components/textinput/BaseTextInputProps.cpp
@@ -102,7 +102,13 @@ BaseTextInputProps::BaseTextInputProps(
rawProps,
"autoCapitalize",
sourceProps.autoCapitalize,
- {})) {}
+ {})),
+ disableKeyboardShortcuts(convertRawProp(
+ context,
+ rawProps,
+ "disableKeyboardShortcuts",
+ sourceProps.disableKeyboardShortcuts,
+ {false})) {}

void BaseTextInputProps::setProp(
const PropsParserContext& context,
@@ -180,6 +186,7 @@ void BaseTextInputProps::setProp(
RAW_SET_PROP_SWITCH_CASE_BASIC(text);
RAW_SET_PROP_SWITCH_CASE_BASIC(mostRecentEventCount);
RAW_SET_PROP_SWITCH_CASE_BASIC(autoCapitalize);
+ RAW_SET_PROP_SWITCH_CASE_BASIC(disableKeyboardShortcuts);
}
}

diff --git a/node_modules/react-native/ReactCommon/react/renderer/components/textinput/BaseTextInputProps.h b/node_modules/react-native/ReactCommon/react/renderer/components/textinput/BaseTextInputProps.h
index bff69fe..27782a1 100644
--- a/node_modules/react-native/ReactCommon/react/renderer/components/textinput/BaseTextInputProps.h
+++ b/node_modules/react-native/ReactCommon/react/renderer/components/textinput/BaseTextInputProps.h
@@ -63,6 +63,8 @@ class BaseTextInputProps : public ViewProps, public BaseTextProps {
bool autoFocus{false};

std::string autoCapitalize{};
+
+ bool disableKeyboardShortcuts{false};
};

} // namespace facebook::react
1 change: 1 addition & 0 deletions src/components/AmountTextInput.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ function AmountTextInput(
// Setting both autoCorrect and spellCheck to false will hide the suggestion.
autoCorrect={false}
spellCheck={false}
disableKeyboardShortcuts
// eslint-disable-next-line react/jsx-props-no-spreading
{...rest}
/>
Expand Down

0 comments on commit 46a5887

Please sign in to comment.