From fb59a30b63e5fd934615adcb50b8823bd49a0c1a Mon Sep 17 00:00:00 2001 From: Steffen Becker Date: Thu, 20 Aug 2026 12:25:27 +0200 Subject: [PATCH] fix: defer the toolbar tick past Svelte's flush MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Tearing down the focused pane's DOM on a layout switch fires blur synchronously inside Svelte's commit; TipTap answers with a focus-meta transaction, and onTransaction's tick write threw state_unsafe_mutation there — aborting the handler before the other panes got the new state. The tick now bumps in a microtask, after the flush, before paint. --- src/lib/components/Editor.svelte | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/lib/components/Editor.svelte b/src/lib/components/Editor.svelte index d7b00ce..e90891c 100644 --- a/src/lib/components/Editor.svelte +++ b/src/lib/components/Editor.svelte @@ -1063,7 +1063,9 @@ import { EMPTY_PAGE_DECOR, type PageDecor } from '../storage/pageDecor'; }, }, onTransaction: ({ editor: e, transaction }) => { - tick++; + // Deferred: a blur tr arrives synchronously when a pane-layout switch tears + // down the focused DOM — inside Svelte's flush, where a $state write throws. + queueMicrotask(() => tick++); // The other pane shows the same state, decorations included. for (const view of paneViews) view?.updateState(e.state); // Mirror this transaction into the labelled undo/redo log for the toolbar's