mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
Re-implement accessibilityHint on Android to use AccessibililltyNodeInfo#setToolTipText instead of contentDescription (#34427)
Summary: https://github.com/facebook/react-native/issues/31056#issuecomment-786349025 >Re-implement accessibilityHint on Android so that rather that concatenate into the contentDescription, it sets the toolTipText property on the AccessibilityNodeInfo (not on the view). This is the closest analog to iOS's hint that Android has, as the text is announced after the contentDescription rather than part of it. It will will not adhere to users preferences on whether they want hints disabled or not, and still has no pause before it like real hints have, but it's far closer than using the contentDescription directly. fixes https://github.com/facebook/react-native/issues/31056 ## Changelog [Android] [Fixed] - Re-implement accessibilityHint on Android to use AccessibililltyNodeInfo#setToolTipText instead of contentDescription Pull Request resolved: https://github.com/facebook/react-native/pull/34427 Test Plan: https://user-images.githubusercontent.com/24992535/184837154-5c65dbf1-1031-4d56-ac1e-066af7e08edc.mp4 Reviewed By: christophpurrer Differential Revision: D38982158 Pulled By: cipolleschi fbshipit-source-id: 7a616e6df9f83bd21ca02cc26b5918986a1d64f8
This commit is contained in:
committed by
Facebook GitHub Bot
parent
04ee52b867
commit
0b70b38547
@@ -317,7 +317,6 @@ public abstract class BaseViewManager<T extends View, C extends LayoutShadowNode
|
||||
private void updateViewContentDescription(@NonNull T view) {
|
||||
final String accessibilityLabel = (String) view.getTag(R.id.accessibility_label);
|
||||
final ReadableMap accessibilityState = (ReadableMap) view.getTag(R.id.accessibility_state);
|
||||
final String accessibilityHint = (String) view.getTag(R.id.accessibility_hint);
|
||||
final List<String> contentDescription = new ArrayList<>();
|
||||
final ReadableMap accessibilityValue = (ReadableMap) view.getTag(R.id.accessibility_value);
|
||||
if (accessibilityLabel != null) {
|
||||
@@ -352,9 +351,6 @@ public abstract class BaseViewManager<T extends View, C extends LayoutShadowNode
|
||||
contentDescription.add(text.asString());
|
||||
}
|
||||
}
|
||||
if (accessibilityHint != null) {
|
||||
contentDescription.add(accessibilityHint);
|
||||
}
|
||||
if (contentDescription.size() > 0) {
|
||||
view.setContentDescription(TextUtils.join(", ", contentDescription));
|
||||
}
|
||||
|
||||
+5
@@ -225,10 +225,15 @@ public class ReactAccessibilityDelegate extends ExploreByTouchHelper {
|
||||
super.onInitializeAccessibilityNodeInfo(host, info);
|
||||
final AccessibilityRole accessibilityRole =
|
||||
(AccessibilityRole) host.getTag(R.id.accessibility_role);
|
||||
final String accessibilityHint = (String) host.getTag(R.id.accessibility_hint);
|
||||
if (accessibilityRole != null) {
|
||||
setRole(info, accessibilityRole, host.getContext());
|
||||
}
|
||||
|
||||
if (accessibilityHint != null) {
|
||||
info.setTooltipText(accessibilityHint);
|
||||
}
|
||||
|
||||
final Object accessibilityLabelledBy = host.getTag(R.id.labelled_by);
|
||||
if (accessibilityLabelledBy != null) {
|
||||
mAccessibilityLabelledBy =
|
||||
|
||||
Reference in New Issue
Block a user