Skip to content

Commit

Permalink
fix(android): a11y - do not provide content description for TextView …
Browse files Browse the repository at this point in the history
…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 <walkerrunpdx@gmail.com>

closes #9588
  • Loading branch information
felixkrautschuk committed Jan 23, 2022
1 parent c35ed94 commit 2890381
Showing 1 changed file with 2 additions and 5 deletions.
7 changes: 2 additions & 5 deletions packages/core/accessibility/index.android.ts
Expand Up @@ -565,8 +565,8 @@ function setAccessibilityDelegate(view: Partial<View>): void {

function applyContentDescription(view: Partial<View>, 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) {
Expand All @@ -582,9 +582,6 @@ function applyContentDescription(view: Partial<View>, forceUpdate?: boolean) {
}

const cls = `applyContentDescription(${view})`;
if (!androidView) {
return null;
}

const titleValue = view['title'] as string;
const textValue = view['text'] as string;
Expand Down

0 comments on commit 2890381

Please sign in to comment.