From dbaf203a590b110a2e435e31748ae338bd2e1824 Mon Sep 17 00:00:00 2001 From: felixkrautschuk Date: Sun, 23 Jan 2022 17:59:02 +0100 Subject: [PATCH] fix(android): a11y - do not provide content description for TextView elements (#9673) Android accessibility services automatically announce the text itself as the description (see https://developer.android.com/guide/topics/ui/accessibility/apps#describe-ui-element) If an a11y property is provided, the content description should also be set for TextView elements to keep the support for Labels/Buttons that only have a font icon as text and therefore need to have an accessibilityLabel. Co-authored-by: Nathan Walker closes #9588 --- packages/core/accessibility/index.android.ts | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/packages/core/accessibility/index.android.ts b/packages/core/accessibility/index.android.ts index 0850510a0..d268265ff 100644 --- a/packages/core/accessibility/index.android.ts +++ b/packages/core/accessibility/index.android.ts @@ -565,8 +565,8 @@ function setAccessibilityDelegate(view: Partial): void { function applyContentDescription(view: Partial, forceUpdate?: boolean) { let androidView = view.nativeViewProtected as android.view.View; - if (!androidView) { - return; + if (!androidView || (androidView instanceof android.widget.TextView && !view._androidContentDescriptionUpdated)) { + return null; } if (androidView instanceof androidx.appcompat.widget.Toolbar) { @@ -582,9 +582,6 @@ function applyContentDescription(view: Partial, forceUpdate?: boolean) { } const cls = `applyContentDescription(${view})`; - if (!androidView) { - return null; - } const titleValue = view['title'] as string; const textValue = view['text'] as string;