From 4cbaad4f7c2b61ff8bdf0cfca07301dfe6cd2f92 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Wed, 9 Sep 2026 08:40:56 +0000 Subject: [PATCH] Fix reset-or-adjust-state Effect in callout Heading Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- packages/editor/src/widgets/callout.tsx | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/packages/editor/src/widgets/callout.tsx b/packages/editor/src/widgets/callout.tsx index ffe43cda..248be380 100644 --- a/packages/editor/src/widgets/callout.tsx +++ b/packages/editor/src/widgets/callout.tsx @@ -228,9 +228,14 @@ function Heading( }); }, [editor, callout.key]); - useEffect(() => { - if (disabled) setChoosing(false); - }, [disabled]); + // Becoming disabled must close the picker immediately, not on the next + // render pass — derive it during render instead of adjusting state in an + // Effect after the fact. + let disabledForRender = useRef(disabled); + if (disabledForRender.current !== disabled) { + disabledForRender.current = disabled; + if (disabled && choosing) setChoosing(false); + } let choose = (value: string) => { if (disabledRef.current) return;