From 91ad9dd5a34a1554cee1fb7e1966383964dae219 Mon Sep 17 00:00:00 2001 From: Kamran Ahmed Date: Sat, 20 May 2023 23:19:19 +0100 Subject: [PATCH] Add search icon in navigation --- src/components/CommandMenu/CommandMenu.tsx | 11 +++++++++++ src/components/Navigation/Navigation.astro | 7 ++++++- src/components/Navigation/navigation.ts | 6 ++++++ 3 files changed, 23 insertions(+), 1 deletion(-) diff --git a/src/components/CommandMenu/CommandMenu.tsx b/src/components/CommandMenu/CommandMenu.tsx index 220bfb439..638d577a8 100644 --- a/src/components/CommandMenu/CommandMenu.tsx +++ b/src/components/CommandMenu/CommandMenu.tsx @@ -61,6 +61,17 @@ export function CommandMenu() { setIsActive(false); }); + useEffect(() => { + function handleToggleTopic(e: any) { + setIsActive(true); + } + + window.addEventListener(`command.k`, handleToggleTopic); + return () => { + window.removeEventListener(`command.k`, handleToggleTopic); + }; + }, []); + useEffect(() => { if (!isActive || !inputRef.current) { return; diff --git a/src/components/Navigation/Navigation.astro b/src/components/Navigation/Navigation.astro index aed4b36d1..8eae92a3f 100644 --- a/src/components/Navigation/Navigation.astro +++ b/src/components/Navigation/Navigation.astro @@ -7,7 +7,6 @@ import AccountDropdown from './AccountDropdown.astro';