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 <walkerrunpdx@gmail.com>

closes #9588
This commit is contained in:
felixkrautschuk
2022-01-23 17:59:02 +01:00
committed by Nathan Walker
parent 57cc4edc8c
commit dbaf203a59

View File

@ -565,8 +565,8 @@ function setAccessibilityDelegate(view: Partial<View>): void {
function applyContentDescription(view: Partial<View>, forceUpdate?: boolean) { function applyContentDescription(view: Partial<View>, forceUpdate?: boolean) {
let androidView = view.nativeViewProtected as android.view.View; let androidView = view.nativeViewProtected as android.view.View;
if (!androidView) { if (!androidView || (androidView instanceof android.widget.TextView && !view._androidContentDescriptionUpdated)) {
return; return null;
} }
if (androidView instanceof androidx.appcompat.widget.Toolbar) { if (androidView instanceof androidx.appcompat.widget.Toolbar) {
@ -582,9 +582,6 @@ function applyContentDescription(view: Partial<View>, forceUpdate?: boolean) {
} }
const cls = `applyContentDescription(${view})`; const cls = `applyContentDescription(${view})`;
if (!androidView) {
return null;
}
const titleValue = view['title'] as string; const titleValue = view['title'] as string;
const textValue = view['text'] as string; const textValue = view['text'] as string;