Skip to content

Commit 3e87cf6

Browse files
fix(web): returning an accent color to its saved value is still saved
Co-Authored-By: Claude Opus 5.5 <[email protected]>
1 parent cc71834 commit 3e87cf6

2 files changed

Lines changed: 12 additions & 1 deletion

File tree

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,9 @@ export function ProviderAccentColorPicker(props: {
170170
const commit = (color: string) => {
171171
const normalized = normalizeProviderAccentColor(color) ?? "";
172172
setDraft({ color: normalized, base: value, previewing: false });
173-
if (normalized !== value) onCommit(normalized);
173+
// Not deduplicated against `value`: it is stale while an earlier commit is
174+
// in flight, so returning to it must still be submitted.
175+
onCommit(normalized);
174176
};
175177

176178
const picker = (

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

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,15 @@ describe("provider accent color picker", () => {
112112
expect(screen.onCommit.mock.calls[0]?.[0]).not.toBe("#ff0000");
113113
});
114114

115+
it("saves a change back to the saved color while the first change is still saving", async () => {
116+
await using screen = await renderAccentPicker("#ff0000");
117+
118+
await userEvent.fill(byLabel("Custom hex accent color"), "#00ff00");
119+
await userEvent.fill(byLabel("Custom hex accent color"), "#ff0000");
120+
121+
expect(screen.onCommit).toHaveBeenLastCalledWith("#ff0000");
122+
});
123+
115124
it("shows the saved color again when it is reverted outside the picker", async () => {
116125
await using screen = await renderAccentPicker("#ff0000");
117126

0 commit comments

Comments
 (0)