Skip to content

fix(client): expand shorthand hex in hexToRgb instead of a NaN channel#5174

Merged
matthewevans merged 1 commit into
phase-rs:mainfrom
jeffrey701:fix/hextorgb-shorthand
Jul 9, 2026
Merged

fix(client): expand shorthand hex in hexToRgb instead of a NaN channel#5174
matthewevans merged 1 commit into
phase-rs:mainfrom
jeffrey701:fix/hextorgb-shorthand

Conversation

@jeffrey701

Copy link
Copy Markdown
Contributor

Problem

hexToRgb (client/src/components/animation/particleEffects.ts) reads fixed byte offsets off the hex string:

const h = hex.replace("#", "");
return { r: parseInt(h.substring(0,2),16), g: parseInt(h.substring(2,4),16), b: parseInt(h.substring(4,6),16) };

For a CSS-legal 3-digit shorthand like #fff, h is "fff", so the blue channel reads h.substring(4, 6) === "" -> parseInt("", 16) === NaN. The result is a corrupt rgb(r, g, NaN) color string, which renders nothing.

Fix

Expand 3-digit shorthand to its 6-digit form (#fff -> ffffff) before parsing.

Test

client/src/components/animation/__tests__/hexToRgb.test.ts — covers 6-digit parsing and asserts shorthand produces no NaN channel.

…aN channel

hexToRgb reads fixed byte offsets (substring 0-2, 2-4, 4-6) off the hex string,
so a CSS-legal 3-digit shorthand like `#fff` leaves the blue channel as
`h.substring(4, 6)` === "" -> parseInt("", 16) === NaN. That produces a
corrupt `rgb(r, g, NaN)` color string which renders nothing. Expand 3-digit
shorthand to its 6-digit form before parsing.
@jeffrey701 jeffrey701 requested a review from matthewevans as a code owner July 6, 2026 04:38
@gemini-code-assist

Copy link
Copy Markdown
Contributor

Warning

You have reached your daily quota limit. Please wait up to 24 hours and I will start processing your requests again!

@matthewevans matthewevans added the defer-fe Frontend/client/UI PR deferred to Matt's direct review label Jul 6, 2026
@matthewevans matthewevans self-assigned this Jul 9, 2026
@matthewevans matthewevans removed the defer-fe Frontend/client/UI PR deferred to Matt's direct review label Jul 9, 2026
@matthewevans matthewevans added this pull request to the merge queue Jul 9, 2026
@matthewevans matthewevans removed their assignment Jul 9, 2026
Merged via the queue into phase-rs:main with commit c1ca00b Jul 9, 2026
11 checks passed
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