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) <noreply@anthropic.com>
This commit is contained in:
Tom MoorandClaude Opus 5 authored and GitHub committed 2026-08-19 16:58:01 -04:00
1 parent e7249cb138
commit 54ccfc76bb
1 file changed
+7 -1
+7 -1
View File
@@ -419,7 +419,13 @@ function SuggestionsMenu<T extends MenuItem>(props: Props<T>) {
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 = (