The modern link attribution platform. Loved by world-class engineering teams at Twilio, Zillow, Jobber, Vercel, Raycast, and more.
TypeScript clickhousemysqlnextjsopen-sourceplanetscaleprismatailwindcsstinybirdtypescriptupstashvercel
Add disabled tooltips to templates combobox and parameter inputs
Tim Wilson1f2f0a605a5a
diff --git a/apps/web/ui/modals/link-builder/utm-modal.tsx b/apps/web/ui/modals/link-builder/utm-modal.tsxindex b9d56860e2..9660dc1964 100644--- a/apps/web/ui/modals/link-builder/utm-modal.tsx+++ b/apps/web/ui/modals/link-builder/utm-modal.tsx@@ -211,7 +211,11 @@ function UTMModalInner({ setShowUTMModal }: UTMModalProps) {{ shouldDirty: true },);}}- disabled={!isValidUrl(url)}+ disabledTooltip={+ isValidUrl(url)+ ? undefined+ : "Enter a destination URL to add UTM parameters"+ }autoFocus/></div>@@ -229,17 +233,20 @@ function UTMModalInner({ setShowUTMModal }: UTMModalProps) {<div className="mt-6 flex items-center justify-between gap-2"><div>- {isValidUrl(url) && (- <FormProvider {...form}>- <UTMTemplatesCombo- onLoad={(params) => {- setValue("url", constructURLFromUTMParams(url, params), {- shouldDirty: true,- });- }}- />- </FormProvider>- )}+ <FormProvider {...form}>+ <UTMTemplatesCombo+ onLoad={(params) => {+ setValue("url", constructURLFromUTMParams(url, params), {+ shouldDirty: true,+ });+ }}+ disabledTooltip={+ isValidUrl(url)+ ? undefined+ : "Enter a destination URL to use UTM templates"+ }+ />+ </FormProvider></div><div className="flex items-center gap-2"><Buttondiff --git a/apps/web/ui/modals/link-builder/utm-templates-combo.tsx b/apps/web/ui/modals/link-builder/utm-templates-combo.tsxindex 93ad51fdce..05ee5c7103 100644--- a/apps/web/ui/modals/link-builder/utm-templates-combo.tsx+++ b/apps/web/ui/modals/link-builder/utm-templates-combo.tsx@@ -14,8 +14,10 @@ import useSWR, { mutate } from "swr";export function UTMTemplatesCombo({onLoad,+ disabledTooltip,}: {onLoad: (params: Record<string, string>) => void;+ disabledTooltip?: string;}) {const { id: workspaceId } = useWorkspace();@@ -112,7 +114,7 @@ export function UTMTemplatesCombo({return false;}}- buttonProps={{ className: "w-fit px-2" }}+ buttonProps={{ className: "w-fit px-2", disabledTooltip }}inputClassName="md:min-w-[200px]"optionClassName="md:min-w-[250px] md:max-w-[350px]"caretdiff --git a/packages/ui/src/utm-builder.tsx b/packages/ui/src/utm-builder.tsxindex e0255abb74..f6210f525c 100644--- a/packages/ui/src/utm-builder.tsx+++ b/packages/ui/src/utm-builder.tsx@@ -1,7 +1,7 @@"use client";import { cn } from "@dub/utils";-import { useEffect, useId, useRef, useState } from "react";+import { ReactNode, useEffect, useId, useRef, useState } from "react";import { useMediaQuery } from "./hooks/use-media-query";import {Flag6,@@ -63,6 +63,7 @@ export function UTMBuilder({onChange,disabled,autoFocus,+ disabledTooltip,className,}: {values: Record<@@ -75,6 +76,7 @@ export function UTMBuilder({) => void;disabled?: boolean;autoFocus?: boolean;+ disabledTooltip?: string | ReactNode;className?: string;}) {const { isMobile } = useMediaQuery();@@ -127,16 +129,20 @@ export function UTMBuilder({</label></div></Tooltip>- <input- type="text"- id={`${id}-${key}`}- ref={idx === 0 ? inputRef : undefined}- placeholder={placeholder}- disabled={disabled}- className="h-full min-w-0 grow rounded-r-md border border-gray-300 placeholder-gray-400 focus:border-gray-500 focus:ring-gray-500 disabled:cursor-not-allowed sm:text-sm"- value={values[key] || ""}- onChange={(e) => onChange(key, e.target.value)}- />+ <div className="min-w-0 grow">+ <DisabledTooltipWrapper disabledTooltip={disabledTooltip}>+ <input+ type="text"+ id={`${id}-${key}`}+ ref={idx === 0 ? inputRef : undefined}+ placeholder={placeholder}+ disabled={disabled || Boolean(disabledTooltip)}+ className="size-full rounded-r-md border border-gray-300 placeholder-gray-400 focus:border-gray-500 focus:ring-gray-500 disabled:cursor-not-allowed sm:text-sm"+ value={values[key] || ""}+ onChange={(e) => onChange(key, e.target.value)}+ />+ </DisabledTooltipWrapper>+ </div></div></div>);@@ -145,3 +151,19 @@ export function UTMBuilder({</div>);}++function DisabledTooltipWrapper({+ children,+ disabledTooltip,+}: {+ children: ReactNode;+ disabledTooltip?: string | ReactNode;+}) {+ return disabledTooltip ? (+ <Tooltip content={disabledTooltip} disableHoverableContent>+ {children}+ </Tooltip>+ ) : (+ children+ );+}