Skip to content

#569 fixed talkBack skipping paragraphs with link by marking them mer…#570

Open
bpappin wants to merge 1 commit into
mikepenz:developfrom
bpappin:feature/569_TalkBack_skips_paragraphs_with_links
Open

#569 fixed talkBack skipping paragraphs with link by marking them mer…#570
bpappin wants to merge 1 commit into
mikepenz:developfrom
bpappin:feature/569_TalkBack_skips_paragraphs_with_links

Conversation

@bpappin
Copy link
Copy Markdown

@bpappin bpappin commented May 27, 2026

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:

  1. Accessibility Semantics Fix: In MarkdownText.kt, we apply semantics { 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.
  2. Outer Container Traversal Grouping: Maintained the outer container wrapping the text segment with isTraversalGroup = true to 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

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Documentation update
  • Code style update (formatting, renaming)
  • Refactoring (no functional changes, no API changes)
  • Build configuration change
  • Other (please describe):

How Has This Been Tested?

The change has been validated against the existing test suite:

  • Test A: Executed the core and Material 3 module unit tests to ensure that the layout, structure, and accessibility semantics trees still pass regression testing:
    ./gradlew :multiplatform-markdown-renderer-m3:jvmTest
  • Manual: Manual testing was conducted using the sample app to keep a human eye int he loop.

Checklist:

  • My code follows the style guidelines of this project
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes
  • Any dependent changes have been merged and published in downstream modules

@bpappin
Copy link
Copy Markdown
Author

bpappin commented May 28, 2026

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.
Maybe merge and apply list semantics.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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) },
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

TalkBack skips paragraphs with links

2 participants