Skip to content

armgit / dub

Public Imported from GitHub
0

The modern link attribution platform. Loved by world-class engineering teams at Twilio, Zillow, Jobber, Vercel, Raycast, and more.

add esc keyboard shortcut

Steven Teyd465af91f517
diff --git a/apps/web/ui/layout/sidebar/app-sidebar-nav.tsx b/apps/web/ui/layout/sidebar/app-sidebar-nav.tsx
index 0f50e343d8..dd3f9b1ce7 100644
--- a/apps/web/ui/layout/sidebar/app-sidebar-nav.tsx
+++ b/apps/web/ui/layout/sidebar/app-sidebar-nav.tsx
@@ -12,7 +12,7 @@ import { usePayoutsCount } from "@/lib/swr/use-payouts-count";
import useProgram from "@/lib/swr/use-program";
import { useProgramSubmittedLeadsCount } from "@/lib/swr/use-program-submitted-leads-count";
import useWorkspace from "@/lib/swr/use-workspace";
-import { useRouterStuff } from "@dub/ui";
+import { useKeyboardShortcut, useRouterStuff } from "@dub/ui";
import {
Bell,
Brush,
@@ -500,7 +500,7 @@ export function AppSidebarNav({
}) {
const { slug } = useParams() as { slug?: string };
const pathname = usePathname();
- const { getQueryString } = useRouterStuff();
+ const { router, getQueryString } = useRouterStuff();
const { data: session } = useSession();
const { plan, defaultProduct, defaultProgramId, trialEndsAt } =
useWorkspace();
@@ -519,6 +519,18 @@ export function AppSidebarNav({
: "links";
}, [slug, pathname]);
+ // Navigate back to the default product when the Escape key is pressed in the workspace settings
+ useKeyboardShortcut(
+ "Escape",
+ () => router.push(`/${slug}/${defaultProduct}`),
+ {
+ enabled: currentArea === "workspaceSettings",
+ priority: 2,
+ modal: false,
+ sheet: false,
+ },
+ );
+
const { program } = useProgram({
enabled: Boolean(currentArea === "program" && defaultProgramId),
});