Prevent initial space when opening with space bar

This commit is contained in:
Talia 2025-01-16 16:26:59 +01:00
parent df795fe894
commit 3f7d435fff
Signed by: darkwiiplayer
GPG key ID: 7808674088232B3E
2 changed files with 3 additions and 2 deletions

View file

@ -3,6 +3,6 @@
"browser": "src/BetterSelect.js",
"type": "module",
"license": "MIT",
"version": "1.3.0",
"version": "1.3.1",
"url": "https://darkwiiplayer.github.io/BetterSelect/"
}

View file

@ -203,6 +203,8 @@ export class BetterSelect extends HTMLElement {
} else {
if (key == " ") {
this.open()
event.preventDefault()
event.stopPropagation()
} else if (key == "Escape") {
this.keyboardSearchBuffer = ""
event.preventDefault()
@ -236,7 +238,6 @@ export class BetterSelect extends HTMLElement {
const timeout = 1000 * (Number(this.getAttribute("search-timeout")) || 1)
const ref = setTimeout(()=> {
console.warn("Clearing buffer: " + this.keyboardSearchBuffer)
this.keyboardSearchBuffer = ""
}, timeout)
this.searchTimeout.signal.addEventListener("abort", () => {