From f87bb95236311d7600584b6701df7447b635cade Mon Sep 17 00:00:00 2001 From: Aaryan Khandelwal <65252264+aaryan610@users.noreply.github.com> Date: Fri, 26 Apr 2024 18:27:32 +0530 Subject: [PATCH] chore: clear search term on escape key (#4289) --- web/components/command-palette/command-modal.tsx | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/web/components/command-palette/command-modal.tsx b/web/components/command-palette/command-modal.tsx index aa36eabed..29734efc9 100644 --- a/web/components/command-palette/command-modal.tsx +++ b/web/components/command-palette/command-modal.tsx @@ -178,7 +178,9 @@ export const CommandModal: React.FC = observer(() => { return 0; }} onKeyDown={(e) => { - // when search is empty and page is undefined + // when search term is not empty, esc should clear the search term + if (e.key === "Escape" && searchTerm) setSearchTerm(""); + // when user tries to close the modal with esc if (e.key === "Escape" && !page && !searchTerm) closePalette();