The modern link attribution platform. Loved by world-class engineering teams at Twilio, Zillow, Jobber, Vercel, Raycast, and more.
TypeScript clickhousemysqlnextjsopen-sourceplanetscaleprismatailwindcsstinybirdtypescriptupstashvercel
Add CMD/CTRL+S to save
Tim Wilson9615633c1d28
diff --git a/apps/web/app/app.dub.co/(dashboard)/[slug]/links/[...link]/page-client.tsx b/apps/web/app/app.dub.co/(dashboard)/[slug]/links/[...link]/page-client.tsxindex 7b364c6796..157b031fa2 100644--- a/apps/web/app/app.dub.co/(dashboard)/[slug]/links/[...link]/page-client.tsx+++ b/apps/web/app/app.dub.co/(dashboard)/[slug]/links/[...link]/page-client.tsx@@ -109,6 +109,11 @@ function LinkBuilder({ link }: { link: ExpandedLinkProps }) {enabled: !isDirty,});+ // Save when CMD+S or CTRL+S is pressed+ useKeyboardShortcut(["meta+s", "ctrl+s"], () => handleSubmit(onSubmit)(), {+ enabled: isDirty,+ });+const [isChangingLink, setIsChangingLink] = useState(false);return (diff --git a/packages/ui/src/hooks/use-keyboard-shortcut.tsx b/packages/ui/src/hooks/use-keyboard-shortcut.tsxindex da365e358f..5b45d4266b 100644--- a/packages/ui/src/hooks/use-keyboard-shortcut.tsx+++ b/packages/ui/src/hooks/use-keyboard-shortcut.tsx@@ -59,10 +59,8 @@ export function useKeyboardShortcut("[data-sheet-overlay]",);- // Ignore shortcuts if the user is holding a modifier key, typing in an input or textarea, or in a modal+ // Ignore shortcuts if the user is typing in an input or textarea, or in a modalif (- e.metaKey ||- e.ctrlKey ||target.tagName === "INPUT" ||target.tagName === "TEXTAREA" ||!!existingModalBackdrop !== !!options.modal ||@@ -70,14 +68,24 @@ export function useKeyboardShortcut()return;+ const pressedKey = [+ ...(e.metaKey ? ["meta"] : []),+ ...(e.ctrlKey ? ["ctrl"] : []),+ ...(e.altKey ? ["alt"] : []),+ e.key,+ ].join("+");+// Ignore shortcut if it doesn't match this listener- if (Array.isArray(key) ? !key.includes(e.key) : e.key !== key) return;+ if (Array.isArray(key) ? !key.includes(pressedKey) : pressedKey !== key)+ return;// Find enabled listeners that match the keyconst matchingListeners = listeners.filter((l) =>l.enabled !== false &&- (Array.isArray(l.key) ? l.key.includes(e.key) : l.key === e.key),+ (Array.isArray(l.key)+ ? l.key.includes(pressedKey)+ : l.key === pressedKey),);if (!matchingListeners.length) return;