From 9396f7ef20ca25c79b3b526cb16892759b17c803 Mon Sep 17 00:00:00 2001 From: Maksim Karmatskikh Date: Thu, 24 Aug 2023 21:44:29 +0600 Subject: [PATCH] UBER-797: Fix popup menu runtime error (#3627) Signed-off-by: Maxim Karmatskikh --- packages/text-editor/src/components/TextEditor.svelte | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/packages/text-editor/src/components/TextEditor.svelte b/packages/text-editor/src/components/TextEditor.svelte index 54de1d993e..735e30db1a 100644 --- a/packages/text-editor/src/components/TextEditor.svelte +++ b/packages/text-editor/src/components/TextEditor.svelte @@ -214,6 +214,13 @@ // I need to copypaste original function and make a little change // with showContextMenu falg shouldShow: ({ editor, view, state, oldState, from, to }) => { + // For some reason shouldShow might be called after dismount and + // after destroing the editor. We should handle this just no to have + // any errors in runtime + if (!element) { + return false + } + const { doc, selection } = state const { empty } = selection