Skip to content

fix(react-color-picker): use nullish fallback in adjustChannel so zero channel values resolve - #36664

Open
Ray Knight (ArrayKnight) wants to merge 2 commits into
microsoft:masterfrom
ArrayKnight:fix/color-picker-adjust-channel-36646
Open

fix(react-color-picker): use nullish fallback in adjustChannel so zero channel values resolve#36664
Ray Knight (ArrayKnight) wants to merge 2 commits into
microsoft:masterfrom
ArrayKnight:fix/color-picker-adjust-channel-36646

Conversation

@ArrayKnight

@ArrayKnight Ray Knight (ArrayKnight) commented Aug 31, 2026

Copy link
Copy Markdown

adjustChannel.ts selects the per-channel action with actions[channel] || actions.hue. The || arm was presumably meant as a default for an unknown channel, but in the code path that reaches it the expression evaluates on the channel's value — so a channel whose value is 0 (zero saturation, zero alpha, …) takes the falsy branch and is handled by the hue action instead of its own. The visible symptom is the slider for that channel rendering with hue's domain: <input value="210" max="100">, with the thumb painted off the end of the track.

The fix is actions[channel] ?? actions.hue, so the fallback fires only when the channel key is genuinely absent. No API or type change.

Fixes #36646.

Extracted from #36656 per maintainer request — each in-tree fix from that PR as an isolated change.

…o channel values resolve

adjustChannel picked its per-channel result with ||, so a legitimately
falsy value — channel value 0 on a fully dark colour — fell through to
the hue branch. Measured consequence: a channel="value" ColorSlider on
a dark colour rendered value="210" max="100", the thumb at 210% of its
own track. ?? falls back only on missing entries.

Found during the windmod ColorPicker planning probes; recorded in the
campaign findings roster as fixed-in-tree.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_013wmpBCYJpDJCLXcScCWz1i
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Aj9uA3rCVgosnh2zNn8qkc
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

1 participant