diff --git a/examples/combobox/aria1.1pattern/js/listbox-combobox.js b/examples/combobox/aria1.1pattern/js/listbox-combobox.js index 5b0660ba9c..146589e698 100644 --- a/examples/combobox/aria1.1pattern/js/listbox-combobox.js +++ b/examples/combobox/aria1.1pattern/js/listbox-combobox.js @@ -45,6 +45,7 @@ aria.ListboxCombobox.prototype.setupEvents = function () { this.input.addEventListener('keyup', this.checkKey.bind(this)); this.input.addEventListener('keydown', this.setActiveItem.bind(this)); this.input.addEventListener('focus', this.checkShow.bind(this)); + this.input.addEventListener('blur', this.checkSelection.bind(this)); this.listbox.addEventListener('click', this.clickItem.bind(this)); }; @@ -152,6 +153,7 @@ aria.ListboxCombobox.prototype.setActiveItem = function (evt) { this.selectItem(activeItem); return; case aria.KeyCode.TAB: + this.checkSelection(); this.hideListbox(); return; default: @@ -229,6 +231,14 @@ aria.ListboxCombobox.prototype.hideListbox = function () { this.onHide(); }; +aria.ListboxCombobox.prototype.checkSelection = function() { + if (this.activeIndex < 0) { + return; + } + var activeItem = this.getItemAt(this.activeIndex); + this.selectItem(activeItem); +}; + aria.ListboxCombobox.prototype.autocompleteItem = function () { var autocompletedItem = this.listbox.querySelector('.focused'); var inputText = this.input.value;