clicking Esc clears autosuggestions

This commit is contained in:
Nolan Lawson 2018-03-30 17:34:10 -07:00
parent 2848d5a417
commit ec80a3847b
1 changed files with 17 additions and 0 deletions

View File

@ -112,6 +112,9 @@
case 40: // down
this.incrementAutosuggestSelected(1, e)
break
case 27: // escape
this.clearAutosuggestions(e)
break
default:
}
},
@ -127,6 +130,7 @@
/* no await */ clickSelectedAutosuggestionEmoji(this.get('realm'))
}
event.preventDefault()
event.stopPropagation()
},
incrementAutosuggestSelected(increment, event) {
let autosuggestionShown = this.store.get('composeAutosuggestionShown')
@ -143,6 +147,19 @@
}
this.store.set({composeAutosuggestionSelected: selected})
event.preventDefault()
event.stopPropagation()
},
clearAutosuggestions(event) {
let autosuggestionShown = this.store.get('composeAutosuggestionShown')
if (!autosuggestionShown) {
return
}
this.store.set({
composeAutosuggestionSearchResults: [],
composeAutosuggestionSelected: 0
})
event.preventDefault()
event.stopPropagation()
}
},
store: () => store,