menu should not show after Esc in singleword mode either

This commit is contained in:
iulia bejan 2020-11-24 19:29:56 +01:00
Родитель 6807d7e6ba
Коммит 4dba363bc5
2 изменённых файлов: 4 добавлений и 8 удалений

Просмотреть файл

@ -21,10 +21,9 @@ export default function query(
const keyIndex = text.lastIndexOf(key, cursor - 1)
if (keyIndex === -1) return
if (multiWord) {
// Stop matching at the lookBackIndex
if (keyIndex < lookBackIndex) return
if (keyIndex < lookBackIndex) return
if (multiWord) {
// Space immediately after activation key
const charAfterKey = text[keyIndex + 1]
if (charAfterKey === ' ') return

Просмотреть файл

@ -87,7 +87,7 @@ class TextExpander {
}
deactivate(cursor?: number) {
cursor = cursor || this.input.selectionEnd || this.lookBackIndex
cursor = cursor || this.lookBackIndex
const menu = this.menu
if (!menu || !this.combobox) return
this.menu = null
@ -203,10 +203,7 @@ class TextExpander {
onKeydown(event: KeyboardEvent) {
if (event.key === 'Escape' && (this.menu || this.combobox)) {
const cancelled = this.expander.dispatchEvent(new CustomEvent('text-expander-dismiss', {cancelable: true}))
if (cancelled) {
return
}
this.deactivate(this.input.selectionEnd || this.lookBackIndex)
event.stopImmediatePropagation()
event.preventDefault()
}