Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Select-only Combobox Example: Fix scroll event listener bug #2723

Merged
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