[cm6] close autocomplete menu on blur

GitOrigin-RevId: e1475e1a1b4a0f05ab2926cfc5612abb3b9f39e8
This commit is contained in:
Dom Kriskovic 2023-05-05 11:21:44 +02:00 committed by Copybot
parent 466011df86
commit 4c2537a753

View file

@ -10,6 +10,7 @@ import { misspelledWordsField } from './misspelled-words'
import { addIgnoredWord } from './ignored-words' import { addIgnoredWord } from './ignored-words'
import { learnWordRequest } from './backend' import { learnWordRequest } from './backend'
import { Word } from './spellchecker' import { Word } from './spellchecker'
import { closeCompletion } from '@codemirror/autocomplete'
const ITEMS_TO_SHOW = 8 const ITEMS_TO_SHOW = 8
@ -118,6 +119,17 @@ export const spellingMenuField = StateField.define<Tooltip | null>({
EditorView.domEventHandlers({ EditorView.domEventHandlers({
contextmenu: handleContextMenuEvent, contextmenu: handleContextMenuEvent,
click: handleClickEvent, 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)
},
}), }),
] ]
}, },