Skip to content
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions content/patterns/combobox/examples/js/select-only.js
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,10 @@ Select.prototype.init = function () {
this.comboEl.addEventListener('blur', this.onComboBlur.bind(this));
this.comboEl.addEventListener('click', this.onComboClick.bind(this));
this.comboEl.addEventListener('keydown', this.onComboKeyDown.bind(this));
this.listboxEl.addEventListener(
'mousedown',
this.onListBoxMouseDown.bind(this)
);

// create options
this.options.map((option, index) => {
Expand Down Expand Up @@ -352,6 +356,12 @@ Select.prototype.onOptionMouseDown = function () {
this.ignoreBlur = true;
};

Select.prototype.onListBoxMouseDown = function () {
// Clicking on the listbox will cause a blur event,
// but we don't want to perform the default keyboard blur action when clicking the scrollbar
this.ignoreBlur = true;
};

Select.prototype.selectOption = function (index) {
// update state
this.activeIndex = index;
Expand Down