Skip to content

Commit 164188c

Browse files
Select-only Combobox Example: Fix scroll event listener bug (pull #2723)
Fixes #2719. Scrollbar on the list for select only would close when user would click on it. --- Co-authored-by: Andrea N. Cardona <[email protected]>
1 parent cd51ccd commit 164188c

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

content/patterns/combobox/examples/js/select-only.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -195,6 +195,7 @@ Select.prototype.init = function () {
195195

196196
// add event listeners
197197
this.comboEl.addEventListener('blur', this.onComboBlur.bind(this));
198+
this.listboxEl.addEventListener('focusout', this.onComboBlur.bind(this));
198199
this.comboEl.addEventListener('click', this.onComboClick.bind(this));
199200
this.comboEl.addEventListener('keydown', this.onComboKeyDown.bind(this));
200201

@@ -239,10 +240,9 @@ Select.prototype.getSearchString = function (char) {
239240
return this.searchString;
240241
};
241242

242-
Select.prototype.onComboBlur = function () {
243-
// do not do blur action if ignoreBlur flag has been set
244-
if (this.ignoreBlur) {
245-
this.ignoreBlur = false;
243+
Select.prototype.onComboBlur = function (event) {
244+
// do nothing if relatedTarget is contained within listboxEl
245+
if (this.listboxEl.contains(event.relatedTarget)) {
246246
return;
247247
}
248248

0 commit comments

Comments
 (0)