Skip to content

Commit

Permalink
set accessibilityValue to text value if there is no error
Browse files Browse the repository at this point in the history
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
  • Loading branch information
fabOnReact committed Jun 8, 2022
1 parent cabb212 commit 318a964
Showing 1 changed file with 3 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -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 !=
Expand Down

0 comments on commit 318a964

Please sign in to comment.