mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
Prevent scrolling with TalkBack if scrolling is disabled in JS
Summary: Right now you can scroll a horizontal ScrollView with TalkBack even if you've disabled scrolling in JS, because our HorizontalScrollView component doesn't prevent the accessibility scroll event (this doesn't seem to happen with vertical ScrollViews for some reason...) This diff adds an accessibility delegate to both of the Android ScrollView components to make sure they're not scrollable if scrolling has been disabled in JS. Changelog: [Internal] Reviewed By: shergin Differential Revision: D23582689 fbshipit-source-id: b670bdb462ab9c963c7125597d60ca97c7d88a9c
This commit is contained in:
committed by
Facebook GitHub Bot
parent
0693d08e2f
commit
f1a8278187
+20
@@ -21,11 +21,14 @@ import android.view.FocusFinder;
|
||||
import android.view.KeyEvent;
|
||||
import android.view.MotionEvent;
|
||||
import android.view.View;
|
||||
import android.view.accessibility.AccessibilityEvent;
|
||||
import android.widget.HorizontalScrollView;
|
||||
import android.widget.OverScroller;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.core.text.TextUtilsCompat;
|
||||
import androidx.core.view.AccessibilityDelegateCompat;
|
||||
import androidx.core.view.ViewCompat;
|
||||
import androidx.core.view.accessibility.AccessibilityNodeInfoCompat;
|
||||
import com.facebook.common.logging.FLog;
|
||||
import com.facebook.infer.annotation.Assertions;
|
||||
import com.facebook.react.bridge.WritableMap;
|
||||
@@ -104,6 +107,23 @@ public class ReactHorizontalScrollView extends HorizontalScrollView
|
||||
mReactBackgroundManager = new ReactViewBackgroundManager(this);
|
||||
mFpsListener = fpsListener;
|
||||
|
||||
ViewCompat.setAccessibilityDelegate(
|
||||
this,
|
||||
new AccessibilityDelegateCompat() {
|
||||
@Override
|
||||
public void onInitializeAccessibilityEvent(View host, AccessibilityEvent event) {
|
||||
super.onInitializeAccessibilityEvent(host, event);
|
||||
event.setScrollable(mScrollEnabled);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onInitializeAccessibilityNodeInfo(
|
||||
View host, AccessibilityNodeInfoCompat info) {
|
||||
super.onInitializeAccessibilityNodeInfo(host, info);
|
||||
info.setScrollable(mScrollEnabled);
|
||||
}
|
||||
});
|
||||
|
||||
mScroller = getOverScrollerFromParent();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user