From 06c87f87aacdd219ec1494d4fc60086210589bbd Mon Sep 17 00:00:00 2001 From: ManuelStaggl <17688572+ManuelStaggl@users.noreply.github.com> Date: Mon, 16 Nov 2026 15:37:36 +0100 Subject: [PATCH] fix: the open sketch sheet follows a theme switch Co-Authored-By: Claude Opus 5.5 --- .../src/renderer/src/assistant/SketchPad.tsx | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/apps/desktop/src/renderer/src/assistant/SketchPad.tsx b/apps/desktop/src/renderer/src/assistant/SketchPad.tsx index d22a8ccd..27ebd411 100644 --- a/apps/desktop/src/renderer/src/assistant/SketchPad.tsx +++ b/apps/desktop/src/renderer/src/assistant/SketchPad.tsx @@ -334,12 +334,27 @@ export function SketchPad({ initial, onClose, onAttach }: { initial: SketchState }, [backgroundUrl]); const shownBackground = background && background.url === backgroundUrl ? background.image : null; + // The sheet takes its colours from the theme, so a theme switch while it is open paints it again (U-25). + const [theme, setTheme] = useState(0); + useEffect(() => { + const query = matchMedia('(prefers-color-scheme: dark)'); + const update = () => { + requestAnimationFrame(() => { + setTheme((count) => count + 1); + }); + }; + query.addEventListener('change', update); + return () => { + query.removeEventListener('change', update); + }; + }, []); + useEffect(() => { const element = canvas.current; const context = element?.getContext('2d'); if (!element || !context) return; paint(context, items, element.width / SKETCH_SIZE.width, { draft, selected, background: shownBackground, screen: true }); - }, [items, draft, selected, shownBackground]); + }, [items, draft, selected, shownBackground, theme]); /** Puts a photo under the open sheet, fitted whole onto the paper; undo takes it away again. */ const placeBackground = async (file: Blob) => {