diff --git a/package.json b/package.json index 20501ee..bd5fae9 100644 --- a/package.json +++ b/package.json @@ -6,7 +6,7 @@ }, "type": "module", "license": "MIT", - "version": "3.0.0", + "version": "3.0.1", "url": "https://darkwiiplayer.github.io/BetterSelect/", "scripts": { "definitions": "tsc src/*.js --declaration --allowJs --emitDeclarationOnly" diff --git a/src/better-select.js b/src/better-select.js index 439ae18..5ee4e0e 100644 --- a/src/better-select.js +++ b/src/better-select.js @@ -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()) }