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 enter submit in comments field

Steven Tey61b499a47ec3
diff --git a/apps/web/ui/modals/link-builder/index.tsx b/apps/web/ui/modals/link-builder/index.tsx
index 8a8d84a003..38c4f6875e 100644
--- a/apps/web/ui/modals/link-builder/index.tsx
+++ b/apps/web/ui/modals/link-builder/index.tsx
@@ -17,6 +17,7 @@ import {
useKeyboardShortcut,
useRouterStuff,
} from "@dub/ui";
+import { useEnterSubmit } from "@dub/ui/src";
import { ArrowTurnLeft } from "@dub/ui/src/icons";
import {
cn,
@@ -121,6 +122,9 @@ function LinkBuilderInner({
formState: { isDirty, isSubmitting, isSubmitSuccessful, errors },
} = useFormContext<LinkFormData>();
+ const formRef = useRef<HTMLFormElement>(null);
+ const { handleKeyDown } = useEnterSubmit(formRef);
+
const [url, domain, key, proxy, title, description] = watch([
"url",
"domain",
@@ -240,6 +244,7 @@ function LinkBuilderInner({
}}
>
<form
+ ref={formRef}
onSubmit={handleSubmit(async (data) => {
// @ts-ignore – exclude extra attributes from `data` object before sending to API
const { user, tags, tagId, ...rest } = data;
@@ -445,6 +450,7 @@ function LinkBuilderInner({
placeholder="Add comments"
value={field.value ?? ""}
onChange={(e) => field.onChange(e.target.value)}
+ onKeyDown={handleKeyDown}
/>
)}
/>