Skip to content

Commit aa6f192

Browse files
committed
Adds shortcut to toggle side menu
1 parent 2376c52 commit aa6f192

File tree

2 files changed

+16
-1
lines changed

2 files changed

+16
-1
lines changed

apps/webapp/app/components/Shortcuts.tsx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,10 @@ function ShortcutContent() {
8282
<Shortcut name="Filter">
8383
<ShortcutKey shortcut={{ key: "f" }} variant="medium/bright" />
8484
</Shortcut>
85+
<Shortcut name="Toggle side menu">
86+
<ShortcutKey shortcut={{ modifiers: ["mod"]}} variant="medium/bright" />
87+
<ShortcutKey shortcut={{ key: "b" }} variant="medium/bright" />
88+
</Shortcut>
8589
<Shortcut name="Select filter">
8690
<ShortcutKey shortcut={{ key: "1" }} variant="medium/bright" />
8791
<Paragraph variant="small" className="ml-1.5">

apps/webapp/app/components/navigation/SideMenu.tsx

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,8 @@ import { useFeatures } from "~/hooks/useFeatures";
4141
import { type MatchedOrganization } from "~/hooks/useOrganizations";
4242
import { type MatchedProject } from "~/hooks/useProject";
4343
import { useHasAdminAccess } from "~/hooks/useUser";
44+
import { useShortcutKeys } from "~/hooks/useShortcutKeys";
45+
import { ShortcutKey } from "../primitives/ShortcutKey";
4446
import { type User } from "~/models/user.server";
4547
import { useCurrentPlan } from "~/routes/_app.orgs.$organizationSlug/route";
4648
import { type FeedbackType } from "~/routes/resources.feedback";
@@ -137,6 +139,11 @@ export function SideMenu({
137139
const { isManagedCloud } = useFeatures();
138140
const featureFlags = useFeatureFlags();
139141

142+
useShortcutKeys({
143+
shortcut: { modifiers: ["mod"], key: "b" },
144+
action: () => setIsCollapsed((prev) => !prev),
145+
});
146+
140147
useEffect(() => {
141148
const handleScroll = () => {
142149
if (borderRef.current) {
@@ -897,8 +904,12 @@ function CollapseToggle({
897904
<AnimatedChevron isHovering={isHovering} isCollapsed={isCollapsed} />
898905
</button>
899906
</TooltipTrigger>
900-
<TooltipContent side="right" className="text-xs">
907+
<TooltipContent side="right" className="flex items-center gap-2 text-xs">
901908
{isCollapsed ? "Expand" : "Collapse"}
909+
<span className="flex items-center">
910+
<ShortcutKey shortcut={{ modifiers: ["mod"] }} variant="small" />
911+
<ShortcutKey shortcut={{ key: "b" }} variant="small" />
912+
</span>
902913
</TooltipContent>
903914
</Tooltip>
904915
</TooltipProvider>

0 commit comments

Comments
 (0)