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 more `shouldDirty`s

Tim Wilson33be0f598e47
diff --git a/apps/web/ui/modals/link-builder/constants.ts b/apps/web/ui/modals/link-builder/constants.ts
index d180b045a9..af94c5b84a 100644
--- a/apps/web/ui/modals/link-builder/constants.ts
+++ b/apps/web/ui/modals/link-builder/constants.ts
@@ -59,7 +59,7 @@ export const MOBILE_MORE_ITEMS = [
shortcutKey: "l",
enabled: (data: LinkFormData) => Boolean(data.password),
remove: (setValue: UseFormSetValue<LinkWithTagsProps>) =>
- setValue("password", null),
+ setValue("password", null, { shouldDirty: true }),
type: "modal",
},
{
@@ -73,8 +73,8 @@ export const MOBILE_MORE_ITEMS = [
shortcutKey: "e",
enabled: (data: LinkFormData) => Boolean(data.expiresAt),
remove: (setValue: UseFormSetValue<LinkWithTagsProps>) => {
- setValue("expiresAt", null);
- setValue("expiredUrl", null);
+ setValue("expiresAt", null, { shouldDirty: true });
+ setValue("expiredUrl", null, { shouldDirty: true });
},
type: "modal",
},
@@ -92,9 +92,9 @@ export const MOBILE_MORE_ITEMS = [
data.ios || data.android || Object.keys(data.geo || {}).length > 0,
),
remove: (setValue: UseFormSetValue<LinkWithTagsProps>) => {
- setValue("ios", null);
- setValue("android", null);
- setValue("geo", null);
+ setValue("ios", null, { shouldDirty: true });
+ setValue("android", null, { shouldDirty: true });
+ setValue("geo", null, { shouldDirty: true });
},
type: "modal",
},
diff --git a/apps/web/ui/modals/link-builder/options-list.tsx b/apps/web/ui/modals/link-builder/options-list.tsx
index 1f1b28cc86..17e5361f89 100644
--- a/apps/web/ui/modals/link-builder/options-list.tsx
+++ b/apps/web/ui/modals/link-builder/options-list.tsx
@@ -56,7 +56,7 @@ export function OptionsList() {
onRemove={() =>
"remove" in item
? item.remove(setValue)
- : setValue(item.key as any, false)
+ : setValue(item.key as any, false, { shouldDirty: true })
}
/>
</motion.div>
diff --git a/apps/web/ui/modals/link-builder/utm-builder.tsx b/apps/web/ui/modals/link-builder/utm-builder.tsx
index 3b3b83e58c..018261c549 100644
--- a/apps/web/ui/modals/link-builder/utm-builder.tsx
+++ b/apps/web/ui/modals/link-builder/utm-builder.tsx
@@ -79,7 +79,9 @@ export function UTMBuilder() {
const params = useMemo(() => getParamsFromURL(url), [url]);
- const [toggledParams, setToggledParams] = useState<string[]>([]);
+ const [toggledParams, setToggledParams] = useState<string[]>(
+ parameters.filter(({ key }) => params[key]).map(({ key }) => key),
+ );
const enabledParameters = useMemo(() => {
return parameters.filter(
@@ -94,13 +96,14 @@ export function UTMBuilder() {
if (!enabled) setToggledParams((prev) => [...prev, key]);
else {
setToggledParams((prev) => prev.filter((k) => k !== key));
- setValue(key as any, "");
+ setValue(key as any, "", { shouldDirty: true });
setValue(
"url",
constructURLFromUTMParams(url, {
...params,
[key]: "",
}),
+ { shouldDirty: true },
);
}
},
@@ -185,13 +188,14 @@ export function UTMBuilder() {
className="h-full grow rounded-r-md border border-gray-300 text-sm placeholder-gray-400 focus:border-gray-500 focus:ring-gray-500"
value={params[key] || ""}
onChange={(e) => {
- setValue(key as any, e.target.value);
+ setValue(key as any, e.target.value, { shouldDirty: true });
setValue(
"url",
constructURLFromUTMParams(url, {
...params,
[key]: e.target.value,
}),
+ { shouldDirty: true },
);
}}
/>