From aacf28778eadfcae2ca33f66697620f7222d804c Mon Sep 17 00:00:00 2001 From: Xin Chen Date: Tue, 3 Jan 2023 13:48:58 -0800 Subject: [PATCH] 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 --- .../facebook/react/uimanager/BaseViewManager.java | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/ReactAndroid/src/main/java/com/facebook/react/uimanager/BaseViewManager.java b/ReactAndroid/src/main/java/com/facebook/react/uimanager/BaseViewManager.java index ee6ab32496e6fc..1a87bb7de2e84d 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/uimanager/BaseViewManager.java +++ b/ReactAndroid/src/main/java/com/facebook/react/uimanager/BaseViewManager.java @@ -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); + } } }