Skip to content

Accept slash alpha in hsl() and percentage alphas in normalize-colors - #59610

Merged
meta-codesync[bot] merged 1 commit into
react:mainfrom
lazerg:fix/issue-59602-hsl-slash-percent-alpha
Oct 30, 2026
Merged

meta-codesync[bot] merged 1 commit into
react:mainfrom
lazerg:fix/issue-59602-hsl-slash-percent-alpha

Conversation

@lazerg

@lazerg lazerg commented Oct 29, 2026

Copy link
Copy Markdown
Contributor

Summary:

normalizeColor returns null for two forms CSS Color 4 accepts, so a view styled with them isn't painted. hsl() only matched three components, while the slash and comma alpha forms were only wired up for hsla(), and every alpha matcher took a plain number, so rgb(0 128 0 / 50%) failed too.

hsl and hsla now share one pattern, the way rgb and rgba already do, and the alpha slot also takes a percentage, which parse1 divides by 100.

Fixes #59602

Changelog:

[GENERAL] [FIXED] - hsl() colors with an alpha, and alphas given as a percentage such as rgb(0 128 0 / 50%), are no longer rejected

Test Plan:

Added cases to normalizeColor-test.js for hsl() with a slash and comma alpha, hsla() without an alpha, and percentage alphas in rgb, rgba, hsl, hsla and hwb. They fail on main and pass with this change.

  • yarn jest packages/normalize-color packages/react-native/Libraries/StyleSheet packages/react-native/Libraries/Animated: 80 passed
  • eslint and prettier on both files: 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
@facebook-github-tools facebook-github-tools Bot added the Shared with Meta Applied via automation to indicate that an Issue or Pull Request has been shared with the team. label Oct 29, 2026
@meta-codesync

meta-codesync Bot commented Oct 29, 2026

Copy link
Copy Markdown

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

@javache javache left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Review automatically exported from Phabricator review in Meta.

@meta-codesync
meta-codesync Bot merged commit 3aee67b into react:main Oct 30, 2026
111 checks passed
@react-native-bot

Copy link
Copy Markdown
Collaborator

This pull request was successfully merged by @lazerg in 3aee67b

When will my fix make it into a release? | How to file a pick request?

@react-native-bot react-native-bot added the Merged This PR has been merged. label Oct 30, 2026
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. Merged This PR has been merged. Shared with Meta Applied via automation to indicate that an Issue or Pull Request has been shared with the team.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

hsl() with a slash alpha, and an alpha given as a percentage, are rejected as colours

3 participants