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.

make sure no existing modal backdrop when listening to pasted links, add autofocus to delete link modal

Steven Teyb611c2623df9
diff --git a/components/app/modals/add-edit-link-modal/index.tsx b/components/app/modals/add-edit-link-modal/index.tsx
index 508b117b13..60207e42c8 100644
--- a/components/app/modals/add-edit-link-modal/index.tsx
+++ b/components/app/modals/add-edit-link-modal/index.tsx
@@ -606,12 +606,18 @@ function AddEditLinkButton({
const handlePaste = (e: ClipboardEvent) => {
const pastedContent = e.clipboardData?.getData("text");
const target = e.target as HTMLElement;
+ const existingModalBackdrop = document.getElementById("modal-backdrop");
- // make sure it's a valid URL and is not being pasted in an input or textarea
+ // make sure:
+ // - pasted content is a valid URL
+ // - user is not typing in an input or textarea
+ // - there is no existing modal backdrop (i.e. no other modal is open)
if (
pastedContent &&
isValidUrl(pastedContent) &&
- !(target.tagName === "INPUT" || target.tagName === "TEXTAREA")
+ target.tagName !== "INPUT" &&
+ target.tagName !== "TEXTAREA" &&
+ !existingModalBackdrop
) {
setShowAddEditLinkModal(true);
}
diff --git a/components/app/modals/delete-link-modal.tsx b/components/app/modals/delete-link-modal.tsx
index 20a572573f..52ceb907d5 100644
--- a/components/app/modals/delete-link-modal.tsx
+++ b/components/app/modals/delete-link-modal.tsx
@@ -110,7 +110,7 @@ function DeleteLinkModal({
id="verification"
pattern={shortlink}
required
- autoFocus={false}
+ autoFocus
className="block w-full rounded-md border-gray-300 pr-10 text-gray-900 placeholder-gray-300 focus:border-gray-500 focus:outline-none focus:ring-gray-500 sm:text-sm"
/>
</div>