Skip to content

Commit 08d6f43

Browse files
committed
add span description
Notes "The Screenreader stops reading the span text when the focus moves on the AccessibilityLink. The issue may be connected to the latest changes. incompatible types: CharSequence cannot be converted to SpannableString
spannableDescription = text.subSequence(start, end); The start and end of the AccessibilityLink need to be updated after changing the length of the string. Complete the functionality and fix all the compile errors" "#35130 (comment) https://github.com/fabriziobertoglio1987/react-native/blob/48a01d006a45c49018d8c3860f40b696b1aa7269/ReactAndroid/src/main/java/com/facebook/react/uimanager/ReactAccessibilityDelegate.java#L600"
1 parent 48a01d0 commit 08d6f43

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

ReactAndroid/src/main/java/com/facebook/react/uimanager/ReactAccessibilityDelegate.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -595,11 +595,10 @@ protected void onPopulateNodeForVirtualView(
595595
return;
596596
}
597597
if (mView instanceof TextView) {
598-
CharSequence textViewText = ((TextView) mView).getText();
599-
SpannableString spannableString = new SpannableString(textViewText);
598+
SpannableString spannableString = new SpannableString(ttsSpan.description);
600599
spannableString.setSpan(
601600
ttsSpan.span,
602-
java.lang.Math.min(textViewText.length(), ttsSpan.start),
601+
java.lang.Math.min(spannableString.length(), ttsSpan.start),
603602
java.lang.Math.max(ttsSpan.start, ttsSpan.end - 1),
604603
0);
605604
node.setContentDescription(spannableString);
@@ -685,9 +684,10 @@ public AccessibilityLinks(ReactTtsSpan[] spans, Spannable text) {
685684

686685
final AccessibleLink link = new AccessibleLink();
687686
link.span = span;
688-
link.start = start;
689-
link.description = text.subSequence(start, end).toString();
690-
link.end = end;
687+
SpannableString spannableDescription = new SpannableString(text.subSequence(start, end));
688+
link.description = spannableDescription.toString();
689+
link.start = spannableDescription.getSpanStart(span);
690+
link.end = spannableDescription.getSpanEnd(span);
691691

692692
// ID is the reverse of what is expected, since the ClickableSpans are returned in reverse
693693
// order due to being added in reverse order. If we don't do this, focus will move to the

0 commit comments

Comments
 (0)