From 085730f481aef17510f07adaa775538b7850ab4f Mon Sep 17 00:00:00 2001 From: fabriziobertoglio1987 Date: Fri, 20 Jan 2023 11:31:00 +0100 Subject: [PATCH] move iOS functionalities to a new PR https://github.com/facebook/react-native/pull/35908 --- .../Text/TextInput/Multiline/RCTUITextView.h | 3 -- .../Text/TextInput/Multiline/RCTUITextView.m | 18 ----------- .../RCTBackedTextInputViewProtocol.h | 3 -- .../Text/TextInput/RCTBaseTextInputView.m | 11 ------- .../TextInput/RCTBaseTextInputViewManager.m | 1 - .../TextInput/Singleline/RCTUITextField.h | 3 -- .../TextInput/Singleline/RCTUITextField.m | 18 ----------- .../TextInput/RCTTextInputComponentView.mm | 32 ------------------- React/Views/UIView+React.h | 1 - React/Views/UIView+React.m | 11 ------- .../textinput/iostextinput/TextInputProps.cpp | 6 ---- .../textinput/iostextinput/TextInputProps.h | 2 -- 12 files changed, 109 deletions(-) diff --git a/Libraries/Text/TextInput/Multiline/RCTUITextView.h b/Libraries/Text/TextInput/Multiline/RCTUITextView.h index 47cc2083e01b04..1215ff0843402f 100644 --- a/Libraries/Text/TextInput/Multiline/RCTUITextView.h +++ b/Libraries/Text/TextInput/Multiline/RCTUITextView.h @@ -26,9 +26,6 @@ NS_ASSUME_NONNULL_BEGIN @property (nonatomic, assign, readonly) BOOL textWasPasted; @property (nonatomic, copy, nullable) NSString *placeholder; @property (nonatomic, strong, nullable) UIColor *placeholderColor; -@property (nonatomic, assign, nullable) NSString *accessibilityErrorMessage; -@property (nonatomic, readwrite, nullable) NSString *currentAccessibilityError; -@property (nonatomic, readwrite, nullable) NSString *previousAccessibilityError; @property (nonatomic, assign) CGFloat preferredMaxLayoutWidth; diff --git a/Libraries/Text/TextInput/Multiline/RCTUITextView.m b/Libraries/Text/TextInput/Multiline/RCTUITextView.m index 88b468eeddf112..62ec0d5354a52d 100644 --- a/Libraries/Text/TextInput/Multiline/RCTUITextView.m +++ b/Libraries/Text/TextInput/Multiline/RCTUITextView.m @@ -121,24 +121,6 @@ - (void)setDefaultTextAttributes:(NSDictionary *)defa [self _updatePlaceholder]; } -- (void)setAccessibilityErrorMessage:(NSString *)accessibilityErrorMessage -{ - self.previousAccessibilityError = [self.currentAccessibilityError mutableCopy]; - self.currentAccessibilityError = accessibilityErrorMessage; - NSString *text = self.attributedText == nil ? @"" : self.attributedText.string; - NSString *lastChar = [text length] == 0 ? @"" : [text substringFromIndex:[text length] - 1]; - if (accessibilityErrorMessage != nil) { - NSString *errorWithLastCharacter = [NSString stringWithFormat: @"%@ %@", lastChar, accessibilityErrorMessage]; - NSString *errorWithText = [NSString stringWithFormat: @"%@ %@", text, accessibilityErrorMessage]; - self.accessibilityValue = errorWithText; - // onChangeText announce only the last typed/deleted character - // more info at https://bit.ly/3zOHsda - UIAccessibilityPostNotification(UIAccessibilityAnnouncementNotification, errorWithLastCharacter); - } else { - self.accessibilityValue = nil; - } -} - - (NSDictionary *)defaultTextAttributes { return _defaultTextAttributes; diff --git a/Libraries/Text/TextInput/RCTBackedTextInputViewProtocol.h b/Libraries/Text/TextInput/RCTBackedTextInputViewProtocol.h index 6bb48d6d42c0e7..686af9e3a363e2 100644 --- a/Libraries/Text/TextInput/RCTBackedTextInputViewProtocol.h +++ b/Libraries/Text/TextInput/RCTBackedTextInputViewProtocol.h @@ -15,9 +15,6 @@ NS_ASSUME_NONNULL_BEGIN @protocol RCTBackedTextInputViewProtocol @property (nonatomic, copy, nullable) NSAttributedString *attributedText; -@property (nonatomic, assign, nullable) NSString *accessibilityErrorMessage; -@property (nonatomic, readwrite, nullable) NSString *currentAccessibilityError; -@property (nonatomic, readwrite, nullable) NSString *previousAccessibilityError; @property (nonatomic, copy, nullable) NSString *placeholder; @property (nonatomic, strong, nullable) UIColor *placeholderColor; @property (nonatomic, assign, readonly) BOOL textWasPasted; diff --git a/Libraries/Text/TextInput/RCTBaseTextInputView.m b/Libraries/Text/TextInput/RCTBaseTextInputView.m index a37b34e661b154..7f2a6e6996366b 100644 --- a/Libraries/Text/TextInput/RCTBaseTextInputView.m +++ b/Libraries/Text/TextInput/RCTBaseTextInputView.m @@ -148,17 +148,6 @@ - (void)setAttributedText:(NSAttributedString *)attributedText textNeedsUpdate = ([self textOf:attributedTextCopy equals:backedTextInputViewTextCopy] == NO); - NSString *currentAccessibilityError = self.backedTextInputView.currentAccessibilityError; - NSString *previousAccessibilityError = self.backedTextInputView.previousAccessibilityError; - BOOL accessibilityErrorMessageWasRemoved = currentAccessibilityError == nil && ![currentAccessibilityError isEqualToString: previousAccessibilityError]; - if (accessibilityErrorMessageWasRemoved) { - BOOL validString = attributedText && [attributedText.string length] != 0; - NSString *lastChar = validString ? [attributedText.string substringFromIndex:[attributedText.string length] - 1] : @""; - self.backedTextInputView.accessibilityValue = nil; - // Triggering the announcement manually fixes screenreader announcement getting cut off - // https://bit.ly/3w18QmV https://bit.ly/3AdVKW3 https://bit.ly/3QHm7c7 https://bit.ly/3BVnmAy - UIAccessibilityPostNotification(UIAccessibilityAnnouncementNotification, lastChar); - } if (eventLag == 0 && textNeedsUpdate) { UITextRange *selection = self.backedTextInputView.selectedTextRange; NSInteger oldTextLength = self.backedTextInputView.attributedText.string.length; diff --git a/Libraries/Text/TextInput/RCTBaseTextInputViewManager.m b/Libraries/Text/TextInput/RCTBaseTextInputViewManager.m index 468859553881a0..47da2cefee5926 100644 --- a/Libraries/Text/TextInput/RCTBaseTextInputViewManager.m +++ b/Libraries/Text/TextInput/RCTBaseTextInputViewManager.m @@ -36,7 +36,6 @@ @implementation RCTBaseTextInputViewManager { RCT_REMAP_VIEW_PROPERTY(autoCorrect, backedTextInputView.autocorrectionType, UITextAutocorrectionType) RCT_REMAP_VIEW_PROPERTY(contextMenuHidden, backedTextInputView.contextMenuHidden, BOOL) RCT_REMAP_VIEW_PROPERTY(editable, backedTextInputView.editable, BOOL) -RCT_REMAP_VIEW_PROPERTY(accessibilityErrorMessage, backedTextInputView.accessibilityErrorMessage, NSString) RCT_REMAP_VIEW_PROPERTY(enablesReturnKeyAutomatically, backedTextInputView.enablesReturnKeyAutomatically, BOOL) RCT_REMAP_VIEW_PROPERTY(keyboardAppearance, backedTextInputView.keyboardAppearance, UIKeyboardAppearance) RCT_REMAP_VIEW_PROPERTY(placeholder, backedTextInputView.placeholder, NSString) diff --git a/Libraries/Text/TextInput/Singleline/RCTUITextField.h b/Libraries/Text/TextInput/Singleline/RCTUITextField.h index 65ad2f63e71a82..b26b41f8693d7b 100644 --- a/Libraries/Text/TextInput/Singleline/RCTUITextField.h +++ b/Libraries/Text/TextInput/Singleline/RCTUITextField.h @@ -27,9 +27,6 @@ NS_ASSUME_NONNULL_BEGIN @property (nonatomic, strong, nullable) UIColor *placeholderColor; @property (nonatomic, assign) UIEdgeInsets textContainerInset; @property (nonatomic, assign, getter=isEditable) BOOL editable; -@property (nonatomic, assign, nullable) NSString *accessibilityErrorMessage; -@property (nonatomic, readwrite, nullable) NSString *currentAccessibilityError; -@property (nonatomic, readwrite, nullable) NSString *previousAccessibilityError; @property (nonatomic, getter=isScrollEnabled) BOOL scrollEnabled; @property (nonatomic, strong, nullable) NSString *inputAccessoryViewID; @property (nonatomic, assign, readonly) CGFloat zoomScale; diff --git a/Libraries/Text/TextInput/Singleline/RCTUITextField.m b/Libraries/Text/TextInput/Singleline/RCTUITextField.m index be9c1db1788f2e..3d116019b89cde 100644 --- a/Libraries/Text/TextInput/Singleline/RCTUITextField.m +++ b/Libraries/Text/TextInput/Singleline/RCTUITextField.m @@ -99,24 +99,6 @@ - (void)setEditable:(BOOL)editable self.enabled = editable; } -- (void)setAccessibilityErrorMessage:(NSString *)accessibilityErrorMessage -{ - self.previousAccessibilityError = [self.currentAccessibilityError mutableCopy]; - self.currentAccessibilityError = accessibilityErrorMessage; - NSString *text = self.attributedText == nil ? @"" : self.attributedText.string; - NSString *lastChar = [text length] == 0 ? @"" : [text substringFromIndex:[text length] - 1]; - if (accessibilityErrorMessage != nil) { - NSString *errorWithLastCharacter = [NSString stringWithFormat: @"%@ %@", lastChar, accessibilityErrorMessage]; - NSString *errorWithText = [NSString stringWithFormat: @"%@ %@", text, accessibilityErrorMessage]; - self.accessibilityValue = errorWithText; - // onChangeText announce only the last typed/deleted character - // more info at https://bit.ly/3zOHsda - UIAccessibilityPostNotification(UIAccessibilityAnnouncementNotification, errorWithLastCharacter); - } else { - self.accessibilityValue = nil; - } -} - - (void)setSecureTextEntry:(BOOL)secureTextEntry { if (self.secureTextEntry == secureTextEntry) { diff --git a/React/Fabric/Mounting/ComponentViews/TextInput/RCTTextInputComponentView.mm b/React/Fabric/Mounting/ComponentViews/TextInput/RCTTextInputComponentView.mm index 22b1492051fac1..156a913c435d6c 100644 --- a/React/Fabric/Mounting/ComponentViews/TextInput/RCTTextInputComponentView.mm +++ b/React/Fabric/Mounting/ComponentViews/TextInput/RCTTextInputComponentView.mm @@ -32,8 +32,6 @@ @implementation RCTTextInputComponentView { UIView *_backedTextInputView; NSUInteger _mostRecentEventCount; NSAttributedString *_lastStringStateWasUpdatedWith; - NSString *currentAccessibilityError; - NSString *previousAccessibilityError; /* * UIKit uses either UITextField or UITextView as its UIKit element for . UITextField is for single line @@ -57,12 +55,6 @@ @implementation RCTTextInputComponentView { */ BOOL _comingFromJS; BOOL _didMoveToWindow; - - /* - * A flag that triggers the accessibilityElement.accessibilityValue update and VoiceOver announcement - * to avoid duplicated announcements of accessibilityErrorMessage more info https://bit.ly/3yfUXD8 - */ - BOOL _errorMessageRemoved; } #pragma mark - UIView overrides @@ -79,7 +71,6 @@ - (instancetype)initWithFrame:(CGRect)frame _ignoreNextTextInputCall = NO; _comingFromJS = NO; _didMoveToWindow = NO; - _errorMessageRemoved = NO; [self addSubview:_backedTextInputView]; } @@ -142,22 +133,6 @@ - (void)updateProps:(Props::Shared const &)props oldProps:(Props::Shared const & _backedTextInputView.editable = newTextInputProps.traits.editable; } - if (newTextInputProps.accessibilityErrorMessage != oldTextInputProps.accessibilityErrorMessage || newTextInputProps.text != oldTextInputProps.text) { - NSString *text = RCTNSStringFromString(newTextInputProps.text); - NSString *error = RCTNSStringFromString(newTextInputProps.accessibilityErrorMessage); - NSString *lastChar = [text length] == 0 ? @"" : [text substringFromIndex:[text length] - 1]; - if ([error length] != 0) { - NSString *errorWithLastCharacter = [NSString stringWithFormat: @"%@ %@", lastChar, error]; - NSString *errorWithText = [NSString stringWithFormat: @"%@ %@", text, error]; - self.accessibilityElement.accessibilityValue = errorWithText; - UIAccessibilityPostNotification(UIAccessibilityAnnouncementNotification, errorWithLastCharacter); - self->_errorMessageRemoved = NO; - } else { - self.accessibilityElement.accessibilityValue = text; - self->_errorMessageRemoved = YES; - } - } - if (newTextInputProps.traits.enablesReturnKeyAutomatically != oldTextInputProps.traits.enablesReturnKeyAutomatically) { _backedTextInputView.enablesReturnKeyAutomatically = newTextInputProps.traits.enablesReturnKeyAutomatically; @@ -619,13 +594,6 @@ - (void)_setAttributedString:(NSAttributedString *)attributedString UITextRange *selectedRange = _backedTextInputView.selectedTextRange; NSInteger oldTextLength = _backedTextInputView.attributedText.string.length; _backedTextInputView.attributedText = attributedString; - if (self->_errorMessageRemoved) { - _backedTextInputView.accessibilityValue = attributedString.string; - self.accessibilityElement.accessibilityValue = attributedString.string; - NSString *lastChar = [attributedString.string substringFromIndex:[attributedString.string length] - 1]; - UIAccessibilityPostNotification(UIAccessibilityAnnouncementNotification, lastChar); - self->_errorMessageRemoved = NO; - } if (selectedRange.empty) { // Maintaining a cursor position relative to the end of the old text. NSInteger offsetStart = [_backedTextInputView offsetFromPosition:_backedTextInputView.beginningOfDocument diff --git a/React/Views/UIView+React.h b/React/Views/UIView+React.h index 1267cd54a6c445..21a70337d7ac9c 100644 --- a/React/Views/UIView+React.h +++ b/React/Views/UIView+React.h @@ -121,7 +121,6 @@ @property (nonatomic, copy) NSArray *accessibilityActions; @property (nonatomic, copy) NSDictionary *accessibilityValueInternal; @property (nonatomic, copy) NSString *accessibilityLanguage; -@property (nonatomic, copy) NSString *accessibilityErrorMessage; /** * Used in debugging to get a description of the view hierarchy rooted at diff --git a/React/Views/UIView+React.m b/React/Views/UIView+React.m index 7fc6240597439e..94ad951e7179d7 100644 --- a/React/Views/UIView+React.m +++ b/React/Views/UIView+React.m @@ -320,17 +320,6 @@ - (NSString *)accessibilityLanguage return objc_getAssociatedObject(self, _cmd); } -- (NSString *)accessibilityErrorMessage -{ - return objc_getAssociatedObject(self, _cmd); -} - -- (void)setAccessibilityErrorMessage:(NSString *)accessibilityErrorMessage -{ - objc_setAssociatedObject( - self, @selector(accessibilityErrorMessage), accessibilityErrorMessage, OBJC_ASSOCIATION_RETAIN_NONATOMIC); -} - - (void)setAccessibilityLanguage:(NSString *)accessibilityLanguage { objc_setAssociatedObject( diff --git a/ReactCommon/react/renderer/components/textinput/iostextinput/TextInputProps.cpp b/ReactCommon/react/renderer/components/textinput/iostextinput/TextInputProps.cpp index da879a2daa97bf..dad0ea7f8ad803 100644 --- a/ReactCommon/react/renderer/components/textinput/iostextinput/TextInputProps.cpp +++ b/ReactCommon/react/renderer/components/textinput/iostextinput/TextInputProps.cpp @@ -87,12 +87,6 @@ TextInputProps::TextInputProps( "selection", sourceProps.selection, std::optional())), - accessibilityErrorMessage(convertRawProp( - context, - rawProps, - "accessibilityErrorMessage", - sourceProps.accessibilityErrorMessage, - {})), inputAccessoryViewID(convertRawProp( context, rawProps, diff --git a/ReactCommon/react/renderer/components/textinput/iostextinput/TextInputProps.h b/ReactCommon/react/renderer/components/textinput/iostextinput/TextInputProps.h index 3c5d310389ad49..bede7451767b36 100644 --- a/ReactCommon/react/renderer/components/textinput/iostextinput/TextInputProps.h +++ b/ReactCommon/react/renderer/components/textinput/iostextinput/TextInputProps.h @@ -68,8 +68,6 @@ class TextInputProps final : public ViewProps, public BaseTextProps { std::string const inputAccessoryViewID{}; - std::string accessibilityErrorMessage{""}; - bool onKeyPressSync{false}; bool onChangeSync{false};