-
-
Notifications
You must be signed in to change notification settings - Fork 78
Fixed talkBack skipping paragraphs with link by marking them merged #570
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
mikepenz
merged 3 commits into
mikepenz:develop
from
bpappin:feature/569_TalkBack_skips_paragraphs_with_links
Jun 7, 2026
+58
−2
Merged
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,6 +1,7 @@ | ||
| package com.mikepenz.markdown.compose.elements | ||
|
|
||
| import androidx.compose.foundation.Image | ||
| import androidx.compose.foundation.layout.Box | ||
| import androidx.compose.foundation.layout.Column | ||
| import androidx.compose.foundation.text.InlineTextContent | ||
| import androidx.compose.runtime.Composable | ||
|
|
@@ -196,9 +197,15 @@ fun MarkdownText( | |
| val segmentDrawModifier = if (extendedSpans != null) { | ||
| segmentModifier.drawBehind(extendedSpans) | ||
| } else segmentModifier | ||
| 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) }, | ||
| style = style, | ||
| inlineContent = resolvedInlineContent, | ||
| onTextLayout = { result -> | ||
|
|
@@ -210,7 +217,18 @@ fun MarkdownText( | |
| } | ||
|
|
||
| if (blockImageRanges.isEmpty()) { | ||
| textSegment(content, containerModifier(modifier)) | ||
| val hasLinks = content.getLinkAnnotations(0, content.length).isNotEmpty() | ||
| if (hasLinks) { | ||
| Box(modifier = containerModifier(modifier)) { | ||
| textSegment(content, Modifier) | ||
| } | ||
| } else { | ||
| textSegment(content, modifier.onPlaced { | ||
| it.parentLayoutCoordinates?.also { coordinates -> | ||
| containerSize.value = coordinates.size.toSize() | ||
| } | ||
| }) | ||
| } | ||
|
Comment on lines
+221
to
+231
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Replaced the custom Box modifier chain with the library's containerModifier(modifier), which preserves the provided modifiers, then pass an empty Modifier to the internal textSegment. |
||
| } else { | ||
| val components = LocalMarkdownComponents.current | ||
| val typography = LocalMarkdownTypography.current | ||
|
|
||
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let me see about adding more testing to this.
but...
The whole point of this change was explicitly to change the semantic structure, so that TalkBack would read the paragraph and links.
It currently skips over the whole paragraph if it has links in it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
added new test:
inline_links_are_individually_discoverable_and_readablein: Semantics
And a little help from gemini to explain it:
Why it relates to
LinkAnnotationand text-skippingLinkAnnotationelements automatically place individual virtual accessibility nodes into the semantics tree so that they can be read. However, because they are children of the text node in the semantics tree, TalkBack attempts to focus on them individually. When TalkBack encounters a complex mix of text and focusable child nodes (the links), it can skip reading the parent text and jump straight to the links, or focus them in an incorrect order.Modifier.semantics(mergeDescendants = true) {}to theTextcomposable, Compose merges these virtual child nodes into the parentTextnode. This prevents TalkBack from jumping focus inside the layout flow, forcing it to read the paragraph as a single cohesive unit.AnnotatedStringcontent and exposes all URL links inside the standard TalkBack local links menu (accessed via standard swipe gestures), allowing the user to select and trigger them.This design pattern is standard practice in Compose development for ensuring correct accessibility ordering when rendering rich text.