Skip to content

Commit

Permalink
fix: hotkey mode to prevent conflict with input field
Browse files Browse the repository at this point in the history
  • Loading branch information
chambaz committed Oct 27, 2023
1 parent 0121619 commit 5a76faa
Showing 1 changed file with 10 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -90,14 +90,17 @@ const DesktopNavbar: FC = () => {

// Navigation in hotkey mode
useHotkeys(
"l, s, b, e, o",
"l, s+1, s+2, b, e, o",
(_, handler: HotkeysEvent) => {
if (isHotkeyMode) {
switch (handler.keys?.join("")) {
case "l":
router.push("/");
break;
case "s":
case "s1":
router.push("/stake");
break;
case "s2":
router.push("/swap");
break;
case "b":
Expand All @@ -114,28 +117,22 @@ const DesktopNavbar: FC = () => {
setShowBadges(false);
}
},
{ preventDefault: currentRoute == "/" ? true : false, enableOnFormTags: true }
{ enableOnFormTags: true }
);

useHotkeys(
"meta+k",
() => {
setShowBadges(true);
setIsHotkeyMode(true);
setTimeout(() => {
setShowBadges(false);
setIsHotkeyMode(false);
}, 5000);
},
{ enableOnFormTags: true }
);

useHotkeys(
"meta+k",
() => {
setShowBadges(false);
},
{ keyup: true, enableOnFormTags: true }
);

return (
<header>
<nav className="fixed w-full top-0 h-[64px] z-30 bg-[#0F1111]">
Expand Down Expand Up @@ -183,7 +180,7 @@ const DesktopNavbar: FC = () => {
color: "#1C2125",
},
}}
badgeContent={"e"}
badgeContent={"s1"}
invisible={!showBadges}
>
<Link
Expand All @@ -206,7 +203,7 @@ const DesktopNavbar: FC = () => {
color: "#1C2125",
},
}}
badgeContent={"s"}
badgeContent={"s2"}
invisible={!showBadges}
>
<Link
Expand Down

0 comments on commit 5a76faa

Please sign in to comment.