mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
Announce accessibility state changes happening in the background (#26624)
Summary: Currently the react native framework doesn't handle the accessibility state changes of the focused item that happen not upon double tapping. Screen reader doesn't get notified when the state of the focused item changes in the background. To fix this problem, post a layout change notification for every state changes on iOS. On Android, send a click event whenever state "checked", "selected" or "disabled" changes. In the case that such states changes upon user's clicking, the duplicated click event will be skipped by Talkback. ## Changelog: [General][Fixed] - Announce accessibility state changes happening in the background Pull Request resolved: https://github.com/facebook/react-native/pull/26624 Test Plan: Add a nested checkbox example which state changes after a delay in the AccessibilityExample. Differential Revision: D17903205 Pulled By: cpojer fbshipit-source-id: 9245ee0b79936cf11b408b52d45c59ba3415b9f9
This commit is contained in:
committed by
Facebook Github Bot
parent
80857f295c
commit
baa66f63d8
@@ -9,6 +9,7 @@ import android.graphics.Color;
|
||||
import android.text.TextUtils;
|
||||
import android.view.View;
|
||||
import android.view.ViewParent;
|
||||
import android.view.accessibility.AccessibilityEvent;
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.core.view.ViewCompat;
|
||||
@@ -170,6 +171,13 @@ public abstract class BaseViewManager<T extends View, C extends LayoutShadowNode
|
||||
&& accessibilityState.getType(STATE_CHECKED) == ReadableType.String)) {
|
||||
updateViewContentDescription(view);
|
||||
break;
|
||||
} else if (view.isAccessibilityFocused()) {
|
||||
// Internally Talkback ONLY uses TYPE_VIEW_CLICKED for "checked" and
|
||||
// "selected" announcements. Send a click event to make sure Talkback
|
||||
// get notified for the state changes that don't happen upon users' click.
|
||||
// For the state changes that happens immediately, Talkback will skip
|
||||
// the duplicated click event.
|
||||
view.sendAccessibilityEvent(AccessibilityEvent.TYPE_VIEW_CLICKED);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user