Exclude disabled options from search
This commit is contained in:
parent
aad018dad0
commit
9900d51342
1 changed files with 4 additions and 1 deletions
|
@ -445,18 +445,21 @@ export class BetterSelect extends HTMLElement {
|
|||
this.close()
|
||||
return
|
||||
}
|
||||
const candidates = /** @type {HTMLElement[]} */(Array.from(this.list.children).filter(child => !child.hasAttribute("hidden")))
|
||||
const candidates = /** @type {HTMLElement[]} */(Array.from(this.list.children).filter(child => !child.hasAttribute("hidden") && !child.part.contains("disabled")))
|
||||
if (candidates.length) {
|
||||
this.setOption(candidates[0])
|
||||
this.close()
|
||||
}
|
||||
}
|
||||
|
||||
static searchHideDisabled = true
|
||||
|
||||
/**
|
||||
* @param {string} value
|
||||
* @param {HTMLElement} item
|
||||
*/
|
||||
match(value, item) {
|
||||
if (/** @type {Object} */(value && this.constructor).searchHideDisabled && item.part.contains("disabled")) return false
|
||||
return item.innerText.toLowerCase().match(value.toLowerCase())
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue