Skip to content
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 8 additions & 3 deletions packages/editor/src/widgets/callout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down