Skip to content

Fix PlatformColor theme attributes that resolve to a ColorStateList on Android - #59606

Open
lazerg wants to merge 1 commit into
react:mainfrom
lazerg:fix/issue-59599-platformcolor-color-state-list
Open

lazerg wants to merge 1 commit into
react:mainfrom
lazerg:fix/issue-59599-platformcolor-color-state-list

Conversation

@lazerg

@lazerg lazerg commented Oct 29, 2026 •

Copy link
Copy Markdown
Contributor

Summary:

On Android, PlatformColor('?attr/textColorPrimary') paints nothing in an AppCompat theme. That attribute resolves to a ColorStateList, so resolveAttribute hands back a TYPE_STRING value (the path of the color XML), and resolveThemeAttribute returned its data, which is a string pool index and not a color. Now, when the resolved value is a string, it loads outValue.resourceId through ResourcesCompat.getColor, the same way the @color/... path already does, which gives the list's default color. Attributes that hold a plain color behave as before.

Fixes #59599

Changelog:

[ANDROID] [FIXED] - Fix PlatformColor theme attributes that resolve to a ColorStateList, such as ?attr/textColorPrimary

Test Plan:

Added ColorPropConverterTest (Robolectric, Theme.AppCompat): ?attr/textColorPrimary must resolve to the same color obtainStyledAttributes(...).getColor() returns for that attribute, and ?android:attr/colorAccent must still resolve to its plain color.

I couldn't run the Gradle unit tests locally (no Android SDK here). They pass in CI, in build_android (ReactAndroid:testDebugUnitTest). ktfmt is clean.

@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 Oct 29, 2026
@github-actions

Copy link
Copy Markdown

Visual regression

No visual differences at 442ed50c1e1e.

ios: no capture

@meta-codesync

meta-codesync Bot commented Oct 29, 2026

Copy link
Copy Markdown

@javache has imported this pull request. If you are a Meta employee, you can view this in D128303755.

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.

Projects

None yet

2 participants