Skip to content

Commit 7f15ab1

Browse files
committed
Escape clears the search
1 parent 65d4cec commit 7f15ab1

1 file changed

Lines changed: 8 additions & 0 deletions

File tree

src/main.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -378,6 +378,14 @@ function setTheme(theme) {
378378
}
379379
});
380380

381+
// On escape, clear search.
382+
searchInput.addEventListener("keydown", (event) => {
383+
if (event.key === "Escape") {
384+
searchInput.value = "";
385+
searchInput.dispatchEvent(new Event("sl-input", {}));
386+
}
387+
});
388+
381389
// Track search input focus state.
382390
searchInput.addEventListener("focusin", () => searchFocused = true);
383391
searchInput.addEventListener("focusout", () => searchFocused = false);

0 commit comments

Comments
 (0)