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.

added preview.dub.sh as preview URL for app

Steven Tey58217f76126a
diff --git a/components/app/links/link-card.tsx b/components/app/links/link-card.tsx
index c0ef547731..071efde118 100644
--- a/components/app/links/link-card.tsx
+++ b/components/app/links/link-card.tsx
@@ -107,8 +107,8 @@ export default function LinkCard({ props }: { props: LinkProps }) {
const shortcuts = ["e", "d", "a", "x"];
const onKeyDown = (e: any) => {
- if (!selected && !openPopover) return;
- if (shortcuts.includes(e.key)) {
+ // only run shortcut logic if link is selected or the 3 dots menu is open
+ if ((selected || openPopover) && shortcuts.includes(e.key)) {
setOpenPopover(false);
switch (e.key) {
case "e":
diff --git a/components/app/modals/add-edit-link-modal/index.tsx b/components/app/modals/add-edit-link-modal/index.tsx
index 7890808a42..b28fb35c23 100644
--- a/components/app/modals/add-edit-link-modal/index.tsx
+++ b/components/app/modals/add-edit-link-modal/index.tsx
@@ -562,7 +562,9 @@ function AddEditLinkButton({
const onKeyDown = useCallback((e: KeyboardEvent) => {
const target = e.target as HTMLElement;
const existingModalBackdrop = document.getElementById("modal-backdrop");
-
+ // only open modal with keyboard shortcut if:
+ // - user is not typing in an input or textarea
+ // - there is no existing modal backdrop (i.e. no other modal is open)
if (
e.key === "c" &&
target.tagName !== "INPUT" &&
diff --git a/lib/constants/index.ts b/lib/constants/index.ts
index d23d7a4228..8dfed0d3e2 100644
--- a/lib/constants/index.ts
+++ b/lib/constants/index.ts
@@ -57,11 +57,16 @@ export const FADE_IN_ANIMATION_SETTINGS = {
export const HOME_HOSTNAMES = new Set([
// comment for better diffs
"dub.sh",
- "preview.dub.sh",
"localhost",
"localhost:3000",
]);
+export const APP_HOSTNAMES = new Set([
+ "app.dub.sh",
+ "app.localhost:3000",
+ "preview.dub.sh",
+]);
+
export const DEFAULT_REDIRECTS = {
home: "https://dub.sh",
signin: "https://app.dub.sh/login",
diff --git a/middleware.ts b/middleware.ts
index d23310de77..a547664d91 100644
--- a/middleware.ts
+++ b/middleware.ts
@@ -1,5 +1,5 @@
import { NextFetchEvent, NextRequest, NextResponse } from "next/server";
-import { DEFAULT_REDIRECTS } from "@/lib/constants";
+import { APP_HOSTNAMES, DEFAULT_REDIRECTS } from "@/lib/constants";
import {
AppMiddleware,
ApiMiddleware,
@@ -28,8 +28,8 @@ export default async function middleware(req: NextRequest, ev: NextFetchEvent) {
const { domain, path, key } = parse(req);
const home = isHomeHostname(domain);
- // for App (app.dub.sh and app.localhost:3000)
- if (domain === "app.dub.sh" || domain === "app.localhost:3000") {
+ // for App (e.g. app.dub.sh)
+ if (APP_HOSTNAMES.has(domain)) {
return AppMiddleware(req);
}