From 8b3e149db6a46039a8231a0f82bac5a5cfda8ef3 Mon Sep 17 00:00:00 2001 From: zsviczian Date: Thu, 12 Feb 2026 22:03:13 +0100 Subject: [PATCH] fix: hex8 regression #10578 (#10773) --- packages/common/src/colors.ts | 2 +- packages/excalidraw/tests/colorInput.test.ts | 5 ++--- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/packages/common/src/colors.ts b/packages/common/src/colors.ts index 54e5c6086a..763510646b 100644 --- a/packages/common/src/colors.ts +++ b/packages/common/src/colors.ts @@ -346,7 +346,7 @@ export const normalizeInputColor = (color: string): string | null => { if (tc.isValid()) { // testing for `#` first fixes a bug on Electron (more specfically, an // Obsidian popout window), where a hex color without `#` is considered valid - if (tc.getFormat() === "hex" && !color.startsWith("#")) { + if (["hex", "hex8"].includes(tc.getFormat()) && !color.startsWith("#")) { return `#${color}`; } return color; diff --git a/packages/excalidraw/tests/colorInput.test.ts b/packages/excalidraw/tests/colorInput.test.ts index 853e7c1a51..827eefb434 100644 --- a/packages/excalidraw/tests/colorInput.test.ts +++ b/packages/excalidraw/tests/colorInput.test.ts @@ -22,9 +22,8 @@ describe("normalizeInputColor", () => { }); it("does NOT add hash to hexa without hash (tinycolor detects as hex8, not hex)", () => { - // Note: tinycolor detects 8-digit hex as "hex8" format, not "hex", - // so the hash prefix logic doesn't apply - expect(normalizeInputColor("ff000080")).toBe("ff000080"); + // Note: tinycolor detects 8-digit hex as "hex8" format, not "hex" + expect(normalizeInputColor("ff000080")).toBe("#ff000080"); }); });