From 318a96420f0593dc59c030193009e9cba31eb666 Mon Sep 17 00:00:00 2001 From: fabriziobertoglio1987 Date: Wed, 8 Jun 2022 23:36:29 +0800 Subject: [PATCH] set accessibilityValue to text value if there is no error when deleting text, the accessibilityValue is not set to the value of the text. For example Erro => Erro Error => Error, the new text is Error (announcing error) Erro => Erro Err => nothing (should be Err) Er => nothing (should be Er) E => nothing (should be E) when we move focus out/back, the announcement is Erro, even if the text is (E, Er or Err) after the fix Erro => Erro Error => Error, the new text is Error (announcing error) Erro => Erro Err => Err Er => Er E => E --- .../ComponentViews/TextInput/RCTTextInputComponentView.mm | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/React/Fabric/Mounting/ComponentViews/TextInput/RCTTextInputComponentView.mm b/React/Fabric/Mounting/ComponentViews/TextInput/RCTTextInputComponentView.mm index 56fa20ee69d5b1..6faf4ccd3285ab 100644 --- a/React/Fabric/Mounting/ComponentViews/TextInput/RCTTextInputComponentView.mm +++ b/React/Fabric/Mounting/ComponentViews/TextInput/RCTTextInputComponentView.mm @@ -134,14 +134,16 @@ - (void)updateProps:(Props::Shared const &)props oldProps:(Props::Shared const & _backedTextInputView.editable = newTextInputProps.traits.editable; } + NSString *text = RCTNSStringFromString(newTextInputProps.text); if (newTextInputProps.accessibilityErrorMessage != oldTextInputProps.accessibilityErrorMessage) { NSString *errorWithText = RCTNSStringFromString(newTextInputProps.accessibilityErrorMessage); - NSString *text = RCTNSStringFromString(newTextInputProps.text); if ([text length] != 0) { errorWithText = [NSString stringWithFormat: @"%@ %@", text, errorWithText]; } self.accessibilityElement.accessibilityValue = errorWithText; UIAccessibilityPostNotification(UIAccessibilityAnnouncementNotification, errorWithText); + } else if (self.accessibilityElement.accessibilityValue != text) { + self.accessibilityElement.accessibilityValue = text; } if (newTextInputProps.traits.enablesReturnKeyAutomatically !=