From 4c2537a753ea3f716b1ceb059e7380963ac0c321 Mon Sep 17 00:00:00 2001 From: Dom Kriskovic Date: Fri, 5 May 2023 11:21:44 +0200 Subject: [PATCH] [cm6] close autocomplete menu on blur GitOrigin-RevId: e1475e1a1b4a0f05ab2926cfc5612abb3b9f39e8 --- .../extensions/spelling/context-menu.ts | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/services/web/frontend/js/features/source-editor/extensions/spelling/context-menu.ts b/services/web/frontend/js/features/source-editor/extensions/spelling/context-menu.ts index 3a6ad49f31..88ed1f9b36 100644 --- a/services/web/frontend/js/features/source-editor/extensions/spelling/context-menu.ts +++ b/services/web/frontend/js/features/source-editor/extensions/spelling/context-menu.ts @@ -10,6 +10,7 @@ import { misspelledWordsField } from './misspelled-words' import { addIgnoredWord } from './ignored-words' import { learnWordRequest } from './backend' import { Word } from './spellchecker' +import { closeCompletion } from '@codemirror/autocomplete' const ITEMS_TO_SHOW = 8 @@ -118,6 +119,17 @@ export const spellingMenuField = StateField.define({ EditorView.domEventHandlers({ contextmenu: handleContextMenuEvent, click: handleClickEvent, + blur: (event, view: EditorView) => { + if ( + event.relatedTarget instanceof HTMLButtonElement && + event.relatedTarget.classList.contains('advanced-ref-search') + ) { + // prevent closing autocomplete menu if "advanced references search" Open button is clicked + return + } + + closeCompletion(view) + }, }), ] },