Skip to content

Commit 0f277f0

Browse files
joevilchesfacebook-github-bot
authored andcommitted
Let LinkMovementMethod take precedence over accessibility delegate when dataDetector is present
Differential Revision: D73549839
1 parent dd52b4e commit 0f277f0

File tree

1 file changed

+11
-1
lines changed
  • packages/react-native/ReactAndroid/src/main/java/com/facebook/react/views/text

1 file changed

+11
-1
lines changed

packages/react-native/ReactAndroid/src/main/java/com/facebook/react/views/text/ReactTextView.java

+11-1
Original file line numberDiff line numberDiff line change
@@ -734,14 +734,23 @@ protected boolean dispatchHoverEvent(MotionEvent event) {
734734
return super.dispatchHoverEvent(event);
735735
}
736736

737+
/**
738+
* Note that if we have a movement method then we DO NOT forward these events to the accessibility
739+
* delegate. This is because the movement method should handle the focus highlighting and
740+
* changing. If we don't do this then we have mutliple selections happening at once. We cannot get
741+
* rid of movement method since links found by Linkify will not be clickable. Also, putting this
742+
* gating in the accessibility delegate itself will break screen reader accessibility more
743+
* generally, since we still need to register virtual views.
744+
*/
737745
@Override
738746
public final void onFocusChanged(
739747
boolean gainFocus, int direction, @Nullable Rect previouslyFocusedRect) {
740748
super.onFocusChanged(gainFocus, direction, previouslyFocusedRect);
741749
AccessibilityDelegateCompat accessibilityDelegateCompat =
742750
ViewCompat.getAccessibilityDelegate(this);
743751
if (accessibilityDelegateCompat != null
744-
&& accessibilityDelegateCompat instanceof ReactTextViewAccessibilityDelegate) {
752+
&& accessibilityDelegateCompat instanceof ReactTextViewAccessibilityDelegate
753+
&& getMovementMethod() == null) {
745754
((ReactTextViewAccessibilityDelegate) accessibilityDelegateCompat)
746755
.onFocusChanged(gainFocus, direction, previouslyFocusedRect);
747756
}
@@ -752,6 +761,7 @@ public boolean dispatchKeyEvent(KeyEvent event) {
752761
AccessibilityDelegateCompat accessibilityDelegateCompat =
753762
ViewCompat.getAccessibilityDelegate(this);
754763
return (accessibilityDelegateCompat != null
764+
&& getMovementMethod() == null
755765
&& accessibilityDelegateCompat instanceof ReactTextViewAccessibilityDelegate
756766
&& ((ReactTextViewAccessibilityDelegate) accessibilityDelegateCompat)
757767
.dispatchKeyEvent(event))

0 commit comments

Comments
 (0)