close the menu if no option is focused on Enter

This commit is contained in:
Sergio Crisostomo 2018-05-08 11:38:04 +02:00
parent 16fc63614f
commit 7e3fc4a522

View file

@ -494,7 +494,8 @@
this.navigateOptions(1);
}
// enter
if (e.key === 'Enter' && this.focusIndex > -1) {
if (e.key === 'Enter') {
if (this.focusIndex === -1) return this.hideMenu();
const optionComponent = this.flatOptions[this.focusIndex];
const option = this.getOptionData(optionComponent.componentOptions.propsData.value);
this.onOptionClick(option);