From 3f7d435fff2ccba87e7db87d40b7aa56faaa1419 Mon Sep 17 00:00:00 2001 From: DarkWiiPlayer Date: Thu, 16 Jan 2025 16:26:59 +0100 Subject: [PATCH] Prevent initial space when opening with space bar --- package.json | 2 +- src/BetterSelect.js | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 7a9b7e1..5d369ca 100644 --- a/package.json +++ b/package.json @@ -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/" } diff --git a/src/BetterSelect.js b/src/BetterSelect.js index 7ec200e..7b06aa4 100644 --- a/src/BetterSelect.js +++ b/src/BetterSelect.js @@ -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", () => {