Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion docs/registry/default/ui/color-picker.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -650,7 +650,8 @@ function ColorPickerImpl(props: ColorPickerImplProps) {
useIsomorphicLayoutEffect(() => {
if (valueProp !== undefined) {
const currentState = store.getState();
const color = hexToRgb(valueProp, currentState.color.a);
const parsed = parseColorString(valueProp);
const color = parsed || { r: 0, g: 0, b: 0, a: currentState.color.a };
Copy link

Copilot AI Dec 28, 2025

Choose a reason for hiding this comment

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

The new parsing logic does not preserve the existing alpha channel value when parsing color formats that don't include alpha information (like hex colors). The old implementation explicitly passed currentState.color.a to preserve it. Consider updating to preserve the current alpha value when the parsed color uses a default alpha value of 1, similar to how it's handled in the HexInput component at line 1298.

Suggested change
const color = parsed || { r: 0, g: 0, b: 0, a: currentState.color.a };
let color = parsed || { r: 0, g: 0, b: 0, a: currentState.color.a };
if (
parsed &&
currentState.color &&
typeof currentState.color.a === "number"
) {
const trimmed = valueProp.trim().toLowerCase();
const isHexWithoutAlpha =
trimmed.startsWith("#") &&
(trimmed.length === 4 || trimmed.length === 7);
if (isHexWithoutAlpha && parsed.a === 1 && currentState.color.a !== 1) {
color = { ...parsed, a: currentState.color.a };
}
}

Copilot uses AI. Check for mistakes.
const hsv = rgbToHsv(color);
store.setColor(color);
store.setHsv(hsv);
Expand Down