feat: voiceover & talkback labels#470
Open
eszlamczyk wants to merge 11 commits into
Open
Conversation
# 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
There was a problem hiding this comment.
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.
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
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.
What/Why?
Adds an
accessibilityLabelsprop onEnrichedMarkdownTextso 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:
UIAccessibilityElements hadaccessibilityContainer = TableContainerViewwhile being vended throughEnrichedMarkdown.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."Heading 1, heading level 1, heading"because we set both an explicit, heading level Nsuffix oncontentDescriptionANDisHeading = true). Mirrors iOS commit675f37fwhich already removed the same suffix on the iOS side.Formel: E = mc^2).shouldGroupAccessibilityChildrendefaults toYESonRCTViewComponentView, which collapsed the entire markdown view into a single VoiceOver focus group. Overridden toNOonEnrichedMarkdown.NSLocalizedString(which would have required shipping.stringsbundles 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:
uiautomator dump --compressedand TalkBackWalked through this checklist on each:
"Heading level 1, heading""A paragraph with an inline link.""link, link"(activates URL on double‑tap)"Top-level bullet, Aufzählungspunkt""Nested bullet, Verschachtelter Aufzählungspunkt""Top-level ordered item, Listenelement 1""Nested ordered item, Verschachteltes Listenelement 1""A top-level blockquote line., Zitat""A nested blockquote line., Verschachteltes Zitat""Zeile 1: Column A, Column B, heading""Zeile 2: Cell A1, Cell B1""Formel: E = mc^2""Sample image, image"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