Skip to content

Commit aacf287

Browse files
Xin Chenfacebook-github-bot
Xin Chen
authored andcommitted
Reset the contentDescription when accessibility text is empty to revoke 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
1 parent ac5cf32 commit aacf287

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

ReactAndroid/src/main/java/com/facebook/react/uimanager/BaseViewManager.java

+7-6
Original file line numberDiff line numberDiff line change
@@ -366,12 +366,13 @@ public void setAccessibilityActions(T view, ReadableArray accessibilityActions)
366366
@ReactProp(name = ViewProps.ACCESSIBILITY_VALUE)
367367
public void setAccessibilityValue(T view, ReadableMap accessibilityValue) {
368368
if (accessibilityValue == null) {
369-
return;
370-
}
371-
372-
view.setTag(R.id.accessibility_value, accessibilityValue);
373-
if (accessibilityValue.hasKey("text")) {
374-
updateViewContentDescription(view);
369+
view.setTag(R.id.accessibility_value, null);
370+
view.setContentDescription(null);
371+
} else {
372+
view.setTag(R.id.accessibility_value, accessibilityValue);
373+
if (accessibilityValue.hasKey("text")) {
374+
updateViewContentDescription(view);
375+
}
375376
}
376377
}
377378

0 commit comments

Comments
 (0)