Skip to content

feat: voiceover & talkback labels#470

Open
eszlamczyk wants to merge 11 commits into
mainfrom
chore/locale-voiceover-audit
Open

feat: voiceover & talkback labels#470
eszlamczyk wants to merge 11 commits into
mainfrom
chore/locale-voiceover-audit

Conversation

@eszlamczyk

@eszlamczyk eszlamczyk commented Jun 29, 2026

Copy link
Copy Markdown
Collaborator

What/Why?

Adds an accessibilityLabels prop on EnrichedMarkdownText so consumers can translate every string spoken by VoiceOver (iOS) and TalkBack (Android) when navigating the rendered markdown. Until now those strings were hardcoded English literals scattered across both native sides, which made non‑English apps impossible to use with a screen reader without forking the library.

The prop is split into logical sub‑groups (list, blockquote, table, math, rotor) so consumers can override just the announcements that matter to them. Every field is optional; defaults are resolved on the JS side (accessibilityLabelDefaults.ts) before being forwarded through codegen, so native code can rely on every field being a concrete string at the point it's consumed.

Defaults intentionally use the no‑plural cardinal form ("List item 2", "Row 2: …") so a single template works in every language without per‑locale plural rules. Placeholders ({n}, {content}, {latex}) are substituted on the native side at speak time.

This PR also fixes several pre‑existing screen‑reader bugs uncovered during the audit:

  • iOS table rows were silently dropped from VoiceOver's swipe order because the row UIAccessibilityElements had accessibilityContainer = TableContainerView while being vended through EnrichedMarkdown.accessibilityElements. The parent now translates each leaf element's frame into its own coordinate space and re‑vends them with the correct container. Row elements are also cached so "next" doesn't reset focus.
  • iOS table scroll layer was being announced as an empty "scroll area" between the last list item and the first table row — hidden from accessibility now.
  • Android headings were double‑announcing ("Heading 1, heading level 1, heading" because we set both an explicit , heading level N suffix on contentDescription AND isHeading = true). Mirrors iOS commit 675f37f which already removed the same suffix on the iOS side.
  • Android math view wasn't exposing accessibility at all — now matches iOS (Formel: E = mc^2).
  • iOS shouldGroupAccessibilityChildren defaults to YES on RCTViewComponentView, which collapsed the entire markdown view into a single VoiceOver focus group. Overridden to NO on EnrichedMarkdown.
  • iOS rotors now use the prop values instead of NSLocalizedString (which would have required shipping .strings bundles per language — bad for a library since the library author would have to support every language a consumer needs).

Testing

Manually verified (via new story) end‑to‑end on:

  • iOS Simulator (iPhone 17 Pro, iOS 26.3) with Accessibility Inspector and VoiceOver
  • Android emulator (Pixel 9, API 36) with uiautomator dump --compressed and TalkBack
  • Android physical device with TalkBack
  • iOS physical device with VoiceOver

Walked through this checklist on each:

# Element Expected announcement
1 Heading "Heading level 1, heading"
2 Paragraph "A paragraph with an inline link."
3 Inline link "link, link" (activates URL on double‑tap)
4 Bullet "Top-level bullet, Aufzählungspunkt"
5 Nested bullet "Nested bullet, Verschachtelter Aufzählungspunkt"
6 Ordered item N "Top-level ordered item, Listenelement 1"
7 Nested ordered N "Nested ordered item, Verschachteltes Listenelement 1"
8 Blockquote line "A top-level blockquote line., Zitat"
9 Nested blockquote "A nested blockquote line., Verschachteltes Zitat"
10 Table header row "Zeile 1: Column A, Column B, heading"
11 Table body row N "Zeile 2: Cell A1, Cell B1"
12 Math "Formel: E = mc^2"
13 Image "Sample image, image"
14 iOS rotors two‑finger twist cycles "Überschriften / Links / Bilder"

The Storybook entry includes 11 individual text controls (one per label) so reviewers can change any string at runtime and hear it update without rebuilding.

PR Checklist

  • Code compiles and runs on iOS
  • Code compiles and runs on Android
  • Updated documentation/README if applicable
  • Ran example app to verify changes
  • E2E tests are passing
  • Required E2E tests have been added (if applicable)

# Conflicts:
#	apps/react-native-example/ios/Podfile.lock
#	packages/react-native-enriched-markdown/android/src/main/java/com/swmansion/enriched/markdown/EnrichedMarkdown.kt
#	packages/react-native-enriched-markdown/android/src/main/java/com/swmansion/enriched/markdown/utils/common/MarkdownViewManagerUtils.kt
#	packages/react-native-enriched-markdown/android/src/math/java/com/swmansion/enriched/markdown/views/MathContainerView.kt
#	packages/react-native-enriched-markdown/ios/EnrichedMarkdown.mm
#	packages/react-native-enriched-markdown/ios/views/TableContainerView.h
@eszlamczyk eszlamczyk requested a review from Copilot June 30, 2026 13:42
@eszlamczyk eszlamczyk marked this pull request as ready for review June 30, 2026 13:43

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

Adds a cross-platform accessibilityLabels prop to let consumers localize all screen-reader announcements produced by rendered markdown, and updates iOS/Android native implementations to use these resolved labels (plus fixes multiple accessibility behavior issues uncovered in the audit).

Changes:

  • Introduces AccessibilityLabels / ResolvedAccessibilityLabels, JS-side defaults, and resolution logic; exports them publicly.
  • Wires resolved labels through codegen into iOS + Android native code (lists, blockquotes, tables, math, and iOS rotors).
  • Updates native accessibility behavior (notably table + math a11y), plus documentation and example/storybook usage.

Reviewed changes

Copilot reviewed 35 out of 35 changed files in this pull request and generated 7 comments.

Show a summary per file
File Description
packages/react-native-enriched-markdown/src/types/MarkdownTextProps.ts Adds the new accessibilityLabels prop to the public component props.
packages/react-native-enriched-markdown/src/types/AccessibilityLabels.ts Defines the label shape and resolved counterpart for consumers/native.
packages/react-native-enriched-markdown/src/native/EnrichedMarkdownText.tsx Resolves defaults on JS side and forwards fully-populated labels to native.
packages/react-native-enriched-markdown/src/index.tsx Exports label types + defaults/resolver from the package entrypoint.
packages/react-native-enriched-markdown/src/EnrichedMarkdownTextNativeComponent.ts Adds codegen prop structs for the accessibility labels (Text variant).
packages/react-native-enriched-markdown/src/EnrichedMarkdownNativeComponent.ts Adds codegen prop structs for the accessibility labels (non-Text variant).
packages/react-native-enriched-markdown/src/accessibilityLabelDefaults.ts Provides default English labels + resolver for partial overrides.
packages/react-native-enriched-markdown/ios/views/TableContainerView.m iOS table: hides scroll layer from a11y; localizes row labels; caches row elements.
packages/react-native-enriched-markdown/ios/views/TableContainerView.h Adds accessibilityLabels property for iOS table segment.
packages/react-native-enriched-markdown/ios/views/ENRMMathContainerView.m iOS math: uses localized label template with {latex} substitution.
packages/react-native-enriched-markdown/ios/views/ENRMMathContainerView.h Adds accessibilityLabels property for iOS math segment.
packages/react-native-enriched-markdown/ios/views/EnrichedMarkdownInternalText.m Passes labels through to accessibility element builder.
packages/react-native-enriched-markdown/ios/views/EnrichedMarkdownInternalText.h Adds accessibilityLabels property for internal text segment.
packages/react-native-enriched-markdown/ios/utils/MarkdownAccessibilityElementBuilder.m iOS: localizes list/blockquotes/rotor names; adjusts element labeling/values.
packages/react-native-enriched-markdown/ios/utils/MarkdownAccessibilityElementBuilder.h Updates builder/rotor signatures to accept labels.
packages/react-native-enriched-markdown/ios/utils/ENRMAccessibilityLabels.m Introduces native iOS container for resolved label strings + defaults.
packages/react-native-enriched-markdown/ios/utils/ENRMAccessibilityLabels.h Declares iOS label fields consumed across views/builders.
packages/react-native-enriched-markdown/ios/input/ENRMFormattingStore.mm Minor formatting-only change.
packages/react-native-enriched-markdown/ios/EnrichedMarkdownText.mm iOS Text view: plumbs resolved labels into builder and rotor generation.
packages/react-native-enriched-markdown/ios/EnrichedMarkdown.mm iOS segmented renderer: propagates labels to segments; changes a11y element vending.
packages/react-native-enriched-markdown/android/src/math/java/com/swmansion/enriched/markdown/views/MathContainerView.kt Android math: makes math focusable and sets localized contentDescription.
packages/react-native-enriched-markdown/android/src/main/java/com/swmansion/enriched/markdown/views/TableContainerView.kt Android table: adds per-row accessibility overlay; hides visual children from a11y.
packages/react-native-enriched-markdown/android/src/main/java/com/swmansion/enriched/markdown/utils/common/MarkdownViewManagerUtils.kt Parses nested accessibilityLabels map into native AccessibilityLabels.
packages/react-native-enriched-markdown/android/src/main/java/com/swmansion/enriched/markdown/EnrichedMarkdownTextManager.kt Adds @ReactProp accessibilityLabels to Text manager.
packages/react-native-enriched-markdown/android/src/main/java/com/swmansion/enriched/markdown/EnrichedMarkdownText.kt Forwards labels into the accessibility helper.
packages/react-native-enriched-markdown/android/src/main/java/com/swmansion/enriched/markdown/EnrichedMarkdownManager.kt Adds @ReactProp accessibilityLabels to segmented manager.
packages/react-native-enriched-markdown/android/src/main/java/com/swmansion/enriched/markdown/EnrichedMarkdownInternalText.kt Wires labels into internal text accessibility helper.
packages/react-native-enriched-markdown/android/src/main/java/com/swmansion/enriched/markdown/EnrichedMarkdown.kt Propagates label updates to segments (incl. optional math via reflection).
packages/react-native-enriched-markdown/android/src/main/java/com/swmansion/enriched/markdown/accessibility/MarkdownAccessibilityHelper.kt Android: localizes list/blockquotes; adjusts heading/link announcements.
packages/react-native-enriched-markdown/android/src/main/java/com/swmansion/enriched/markdown/accessibility/AccessibilityLabels.kt Adds Android-side label defaults container.
docs/API_REFERENCE.md Documents the new accessibilityLabels prop and its shape.
docs/ACCESSIBILITY.md Adds a guide section detailing defaults, placeholders, and per-element behavior.
apps/react-native-example/src/screens/playground/PlaygroundScreen.tsx Changes playground input defaults (autofocus + default value).
apps/react-native-example/src/App.tsx Replaces example app navigation with a single-screen markdown demo.
apps/react-native-example/.rnstorybook/stories/components/EnrichedMarkdownText/props/AccessibilityLabels.stories.tsx Adds Storybook story to exercise label overrides at runtime.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread packages/react-native-enriched-markdown/src/types/AccessibilityLabels.ts Outdated
Comment thread packages/react-native-enriched-markdown/src/types/AccessibilityLabels.ts Outdated
Comment thread docs/API_REFERENCE.md
Comment thread docs/ACCESSIBILITY.md
Comment thread apps/react-native-example/src/App.tsx Outdated
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
@eszlamczyk eszlamczyk requested a review from hryhoriiK97 June 30, 2026 14:17
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.

2 participants