Skip to content

Commit

Permalink
Reset the contentDescription when accessibility text is empty to revo…
Browse files Browse the repository at this point in the history
…ke stale state

Summary:
This diff fixes accessibility value setter in BaseViewManager.java when the accessibility value is null. This is needed when we reset the value and would like to make sure the content description reflects the expected state, instead of the stale state when the value is set last time.

Changelog:
[Android][Fixed] - Reset accessibility value when it gets a null value

Reviewed By: NickGerleman

Differential Revision: D42160904

fbshipit-source-id: a8115a268461c8340d38350ab6fd3f21e4b14959
  • Loading branch information
Xin Chen authored and facebook-github-bot committed Jan 3, 2023
1 parent ac5cf32 commit aacf287
Showing 1 changed file with 7 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -366,12 +366,13 @@ public void setAccessibilityActions(T view, ReadableArray accessibilityActions)
@ReactProp(name = ViewProps.ACCESSIBILITY_VALUE)
public void setAccessibilityValue(T view, ReadableMap accessibilityValue) {
if (accessibilityValue == null) {
return;
}

view.setTag(R.id.accessibility_value, accessibilityValue);
if (accessibilityValue.hasKey("text")) {
updateViewContentDescription(view);
view.setTag(R.id.accessibility_value, null);
view.setContentDescription(null);
} else {
view.setTag(R.id.accessibility_value, accessibilityValue);
if (accessibilityValue.hasKey("text")) {
updateViewContentDescription(view);
}
}
}

Expand Down

0 comments on commit aacf287

Please sign in to comment.