mirror of
https://github.com/NativeScript/NativeScript.git
synced 2025-08-15 11:01:21 +08:00
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:

committed by
Nathan Walker

parent
57cc4edc8c
commit
dbaf203a59
@ -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) {
|
||||
@ -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;
|
||||
|
Reference in New Issue
Block a user