fix: leaving a header/footer no longer throws state_unsafe_mutation
Clearing hfActive removes the live zone's DOM during Svelte's flush; ProseMirror dispatches a blur transaction as it goes, and the hfTick mutation in onTransaction then landed mid-render and threw, aborting the rest of the batch. The tick is queued to the next microtask instead.
This commit is contained in:
1 parent
6eb9032c46
commit
dc1f5bb7b1
1 file changed
+3
-1
@@ -337,8 +337,10 @@
|
||||
content: (zoneDoc(editingIndex, zone, editingVariant) ?? emptyDoc()) as Content,
|
||||
// No autofocus: its scrollIntoView nudges the page so the just-clicked zone
|
||||
// appears to jump. Focus the zone explicitly without scrolling instead.
|
||||
// Deferred: leaving a zone removes this DOM mid-render, and the blur ProseMirror
|
||||
// dispatches then would tick state while Svelte is still flushing.
|
||||
onTransaction: () => {
|
||||
hfTick++;
|
||||
queueMicrotask(() => hfTick++);
|
||||
},
|
||||
onUpdate: ({ editor }) => {
|
||||
writeZone(editingIndex, zone, editingVariant, editor.getJSON() as HfDoc);
|
||||
|
||||
Reference in new issue
Block a user