From 7934e9ac7184a84e17d8bcbdfdaa48e9aa210bb7 Mon Sep 17 00:00:00 2001 From: Jos de Jong Date: Thu, 28 Apr 2022 15:41:31 +0200 Subject: [PATCH] fix: right click in welcome screen did not open the context menu --- .../components/modes/treemode/TreeMode.svelte | 22 ++++++++++--------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/src/lib/components/modes/treemode/TreeMode.svelte b/src/lib/components/modes/treemode/TreeMode.svelte index ab07910b..88c8b330 100644 --- a/src/lib/components/modes/treemode/TreeMode.svelte +++ b/src/lib/components/modes/treemode/TreeMode.svelte @@ -1906,7 +1906,7 @@ } function handleContextMenu(event) { - if (readOnly || !selection || selection.edit || !refContents) { + if (readOnly || selection?.edit) { return } @@ -1927,7 +1927,7 @@ } else { // type === 'keydown' (from the quick key Ctrl+Q) // or target is hidden input -> context menu button on keyboard - const anchor = refContents.querySelector('.context-menu-button.selected') + const anchor = refContents?.querySelector('.context-menu-button.selected') if (anchor) { openContextMenu({ anchor, @@ -1938,14 +1938,16 @@ }) } else { // fallback on just displaying the ContextMenu top left - const rect = refContents.getBoundingClientRect() - openContextMenu({ - top: rect.top + 2, - left: rect.left + 2, - width: CONTEXT_MENU_WIDTH, - height: CONTEXT_MENU_HEIGHT, - showTip: false - }) + const rect = refContents?.getBoundingClientRect() + if (rect) { + openContextMenu({ + top: rect.top + 2, + left: rect.left + 2, + width: CONTEXT_MENU_WIDTH, + height: CONTEXT_MENU_HEIGHT, + showTip: false + }) + } } }