Skip to content

Commit 0bdae8c

Browse files
only21milclaude
andcommitted
fix(web): keep theme color alpha when a hex value is typed
The picker's HEX field committed the bare 6-digit value, so typing a hex made a translucent theme color opaque. The RGB field and the sliders already append the stored alpha; the HEX field now does the same. Co-Authored-By: Claude Opus 5.5 <[email protected]>
1 parent 05696c6 commit 0bdae8c

2 files changed

Lines changed: 9 additions & 1 deletion

File tree

‎apps/web/src/components/settings/ThemeColorPicker.tsx‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ function ThemeColorPickerPanel({
145145
const nextHsv = hexToHsv(nextValue);
146146
setHsv(nextHsv);
147147
setRgbDraft(themeRgbValue(nextValue));
148-
onChange(nextValue.toLowerCase());
148+
onChange(nextValue.toLowerCase() + alphaSuffix);
149149
};
150150

151151
const handleRgbChange = (nextValue: string) => {

‎apps/web/src/components/settings/colorPickers.browser.test.tsx‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,4 +81,12 @@ describe("theme color field", () => {
8181
await echo("#ffffff");
8282
expect(slider(HUE).getAttribute("aria-valuenow")).toBe("10");
8383
});
84+
85+
it("keeps a translucent color's alpha when a hex value is typed", async () => {
86+
await using screen = await renderThemeField("#22ccff80");
87+
const { onChange } = screen;
88+
89+
await userEvent.fill(byLabel("Accent color picker hex value"), "#ff0000");
90+
expect(onChange).toHaveBeenLastCalledWith("accent", "#ff000080");
91+
});
8492
});

0 commit comments

Comments
 (0)