#569 fixed talkBack skipping paragraphs with link by marking them mer…#570
Open
bpappin wants to merge 1 commit into
Open
#569 fixed talkBack skipping paragraphs with link by marking them mer…#570bpappin wants to merge 1 commit into
bpappin wants to merge 1 commit into
Conversation
Author
|
By the way @mikepenz i noticed that in TalkBack, when navigating over list items, TalkBack selects the point first, then the content as the next item. You could probably use a similar technique (or add to this) to improve how that works. |
Contributor
There was a problem hiding this comment.
Pull request overview
Fixes an accessibility issue where Android TalkBack can skip reading paragraphs that contain inline links by adjusting Compose semantics for markdown text rendering.
Changes:
- Applies
semantics(mergeDescendants = true)on text segments that contain link annotations. - Conditionally wraps link-containing content in a traversal-group container to preserve TalkBack reading order.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+221
to
+235
| if (hasLinks) { | ||
| Box(modifier = Modifier.semantics { isTraversalGroup = true }.onPlaced { | ||
| it.parentLayoutCoordinates?.also { coordinates -> | ||
| containerSize.value = coordinates.size.toSize() | ||
| } | ||
| }) { | ||
| textSegment(content, modifier) | ||
| } | ||
| } else { | ||
| textSegment(content, modifier.onPlaced { | ||
| it.parentLayoutCoordinates?.also { coordinates -> | ||
| containerSize.value = coordinates.size.toSize() | ||
| } | ||
| }) | ||
| } |
Comment on lines
+200
to
+208
| val hasSegmentLinks = segment.getLinkAnnotations(0, segment.length).isNotEmpty() | ||
| val finalModifier = if (hasSegmentLinks) { | ||
| segmentDrawModifier.semantics(mergeDescendants = true) { } | ||
| } else { | ||
| segmentDrawModifier | ||
| } | ||
| MarkdownBasicText( | ||
| text = extended, | ||
| modifier = segmentDrawModifier.let { animations.animateTextSize(it) }, | ||
| modifier = finalModifier.let { animations.animateTextSize(it) }, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fix TalkBack skipping paragraphs with inline links
Description
This PR resolves an accessibility issue where screen readers (such as Android TalkBack) would skip reading entire paragraphs of text if they contained inline link annotations.
Key Changes:
MarkdownText.kt, we applysemantics { mergeDescendants = true }to the text segment modifier when link annotations are present. This forces screen readers to group and read the paragraph containing links as a cohesive text unit instead of skipping it or focusing links out of order.isTraversalGroup = trueto preserve correct layout traversal order as expected by regression tests.Note
Running the test suite locally required fixing an asynchronous timing/import issue in
MarkdownA11yTest.kt. That test fix has been excluded from this PR as it is out of scope.Fixes #569
Type of change
How Has This Been Tested?
The change has been validated against the existing test suite:
./gradlew :multiplatform-markdown-renderer-m3:jvmTestChecklist: