From e4383cb3bd0d0fb8c83e7b2a863c2a92eed55b30 Mon Sep 17 00:00:00 2001 From: Kaz Wesley Date: Mon, 26 Feb 2024 15:41:47 -0500 Subject: [PATCH] Fix CB reloading when vis-selector opened (#9192) Fixes a bug blocking #8570. --- app/ide-desktop/lib/dashboard/src/App.tsx | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/app/ide-desktop/lib/dashboard/src/App.tsx b/app/ide-desktop/lib/dashboard/src/App.tsx index 139411eb1b54..bfc3090ed015 100644 --- a/app/ide-desktop/lib/dashboard/src/App.tsx +++ b/app/ide-desktop/lib/dashboard/src/App.tsx @@ -195,7 +195,18 @@ function AppRouter(props: AppProps) { !(event.target instanceof HTMLTextAreaElement) && !(event.target instanceof HTMLElement && event.target.isContentEditable) ) { - document.getSelection()?.removeAllRanges() + const selection = document.getSelection() + const app = document.getElementById('app') + const appContainsSelection = + app != null && + selection != null && + selection.anchorNode != null && + app.contains(selection.anchorNode) && + selection.focusNode != null && + app.contains(selection.focusNode) + if (selection != null && !appContainsSelection) { + selection.removeAllRanges() + } } } const onSelectStart = () => {