Skip to content

Commit

Permalink
Issue 495; Select item on blur
Browse files Browse the repository at this point in the history
  • Loading branch information
tatermelon committed Nov 2, 2017
1 parent 2549421 commit c6499aa
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions examples/combobox/aria1.1pattern/js/listbox-combobox.js
Original file line number Diff line number Diff line change
Expand Up @@ -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));
};

Expand Down Expand Up @@ -152,6 +153,7 @@ aria.ListboxCombobox.prototype.setActiveItem = function (evt) {
this.selectItem(activeItem);
return;
case aria.KeyCode.TAB:
this.checkSelection();
this.hideListbox();
return;
default:
Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit c6499aa

Please sign in to comment.