From 54ccfc76bb2a645c2a898e16ea9ad0add3edc45d Mon Sep 17 00:00:00 2001 From: Tom Moor Date: Wed, 19 Aug 2026 16:58:01 -0400 Subject: [PATCH] fix: Crash inserting a math block from the suggestions menu (#13495) Opening the nested math editor moves focus, which dismisses the suggestions menu. Restoring focus to the outer view re-entered the node view's selection handling before it had finished, throwing "inner view should not exist!". Fixes OUTLINE-CLOUD-BZA Co-authored-by: Claude Opus 5 (1M context) --- app/editor/components/SuggestionsMenu.tsx | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/app/editor/components/SuggestionsMenu.tsx b/app/editor/components/SuggestionsMenu.tsx index 13378cf2f5..051098d575 100644 --- a/app/editor/components/SuggestionsMenu.tsx +++ b/app/editor/components/SuggestionsMenu.tsx @@ -419,7 +419,13 @@ function SuggestionsMenu(props: Props) { const close = React.useCallback(() => { props.onClose(); - view.focus(); + + // Don't steal focus back from a nested editor, such as the one inside a + // math node, that took it while the menu was closing. + const focused = view.dom.ownerDocument.activeElement; + if (focused === view.dom || !view.dom.contains(focused)) { + view.focus(); + } }, [props, view]); const handleLinkInputKeydown = (