Skip to content

Removed timeout code for reseting search string in select only combobox example #3304

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all 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
19 changes: 1 addition & 18 deletions content/patterns/combobox/examples/js/select-only.js
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,6 @@ const Select = function (el, options = []) {
this.activeIndex = 0;
this.open = false;
this.searchString = '';
this.searchTimeout = null;

// init
if (el && this.comboEl && this.listboxEl) {
Expand Down Expand Up @@ -226,22 +225,6 @@ Select.prototype.createOption = function (optionText, index) {
return optionEl;
};

Select.prototype.getSearchString = function (char) {
// reset typing timeout and start new timeout
// this allows us to make multiple-letter matches, like a native select
if (typeof this.searchTimeout === 'number') {
window.clearTimeout(this.searchTimeout);
}

this.searchTimeout = window.setTimeout(() => {
this.searchString = '';
}, 500);

// add most recent letter to saved search string
this.searchString += char;
return this.searchString;
};

Select.prototype.onLabelClick = function () {
this.comboEl.focus();
};
Expand Down Expand Up @@ -302,7 +285,7 @@ Select.prototype.onComboType = function (letter) {
this.updateMenuState(true);

// find the index of the first matching option
const searchString = this.getSearchString(letter);
const searchString = letter;
const searchIndex = getIndexByLetter(
this.options,
searchString,
Expand Down
Loading