Skip to content

Don't expose Text style spans in Android accessibility node text (#60226) - #60226

Open
cipolleschi wants to merge 1 commit into
react:mainfrom
cipolleschi:export-D130207069
Open

cipolleschi wants to merge 1 commit into
react:mainfrom
cipolleschi:export-D130207069

Conversation

@cipolleschi

@cipolleschi cipolleschi commented Nov 23, 2026 •

Copy link
Copy Markdown
Contributor

Summary:

ReactForegroundColorSpan and ReactBackgroundColorSpan now extend CharacterStyle, and ReactAbsoluteSizeSpan extends MetricAffectingSpan, instead of subclassing Android's built-in colour and size spans. They keep the same drawing and measurement behaviour and the existing colour and size getters, but no longer implement ParcelableSpan. Android therefore does not send these rendering-only spans to accessibility services.

This fixes screen readers announcing colour and size styling for both <Text> and <TextInput>, without copying accessibility text or filtering its spans. Link, text-to-speech and locale spans remain intact.

Changelog:
[Android][Fixed] - Prevent screen readers from announcing colour and size styling in <Text> and <TextInput>

Differential Revision: D130207069

@meta-codesync

meta-codesync Bot commented Nov 23, 2026

Copy link
Copy Markdown

@cipolleschi has exported this pull request. If you are a Meta employee, you can view the originating Diff in D130207069.

@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Nov 23, 2026
@github-actions

github-actions Bot commented Nov 23, 2026 •

Copy link
Copy Markdown

Visual regression

No visual differences at 459b34844354.

ios: no capture

@meta-codesync meta-codesync Bot changed the title Don't expose Text style spans in Android accessibility node text Don't expose Text style spans in Android accessibility node text (#60226) Nov 23, 2026
cipolleschi added a commit to cipolleschi/react-native that referenced this pull request Nov 23, 2026
…ct#60226)

Summary:

On Android, the accessibility node text of a `<Text>` was the rendered `Spanned`, including the visual spans React Native attaches for rendering (foreground/background color, absolute size, typeface, line height, ...). Some screen readers announce these spans along with the text, e.g. "start color black, background color black, 48 pixels". The node text is now a plain copy that keeps only spans with accessibility meaning (`ClickableSpan`, including `URLSpan` and React Native link spans, plus `TtsSpan` and `LocaleSpan`). This applies to both `PreparedLayoutTextView` and `ReactTextView`. Keeping `ClickableSpan` preserves link semantics when the whole text is a single link. For `ReactTextView` the copy is built from the view's own text, so link activation still resolves the original clickable spans. Rendering, layout, hit-testing and inline link virtual views are unchanged.

Changelog:
[Android][Fixed] - Screen readers no longer announce `<Text>` styling (color, size) as part of its accessible text

Differential Revision: D130207069
…ct#60226)

Summary:

`ReactForegroundColorSpan` and `ReactBackgroundColorSpan` now extend `CharacterStyle`, and `ReactAbsoluteSizeSpan` extends `MetricAffectingSpan`, instead of subclassing Android's built-in colour and size spans. They keep the same drawing and measurement behaviour and the existing colour and size getters, but no longer implement `ParcelableSpan`. Android therefore does not send these rendering-only spans to accessibility services.

This fixes screen readers announcing colour and size styling for both `<Text>` and `<TextInput>`, without copying accessibility text or filtering its spans. Link, text-to-speech and locale spans remain intact.

Changelog:
[Android][Fixed] - Prevent screen readers from announcing colour and size styling in `<Text>` and `<TextInput>`

Differential Revision: D130207069

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. meta-exported p: Facebook Partner: Facebook Partner

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant