The modern link attribution platform. Loved by world-class engineering teams at Twilio, Zillow, Jobber, Vercel, Raycast, and more.
TypeScript clickhousemysqlnextjsopen-sourceplanetscaleprismatailwindcsstinybirdtypescriptupstashvercel
Update combobox+input combo focus states
Tim Wilson7d1556299158
diff --git a/apps/web/ui/links/short-link-input-new.tsx b/apps/web/ui/links/short-link-input-new.tsxindex 89dc7e9eba..fe4fba6982 100644--- a/apps/web/ui/links/short-link-input-new.tsx+++ b/apps/web/ui/links/short-link-input-new.tsx@@ -240,31 +240,14 @@ export const ShortLinkInputNew = forwardRef<)}</div><div className="relative mt-1 flex rounded-md shadow-sm">- <div className="">- {/* <select- tabIndex={-1}- disabled={lockKey}- value={domain}- onChange={(e) => {- setKeyError(null);- onChange?.({ domain: e.target.value });- }}- className={cn(- "max-w-[12rem] rounded-l-md border border-r-0 border-gray-300 bg-gray-50 pl-4 pr-8 text-gray-500 focus:border-gray-300 focus:outline-none focus:ring-0 sm:text-sm",- lockKey && "cursor-not-allowed",- loading && "w-[6rem] text-transparent",- )}- >- {domains?.map(({ slug }) => (- <option key={slug} value={slug}>- {punycode(slug)}- </option>- ))}- </select> */}+ <div className="z-[1]"><Comboboxselected={domain && !loading- ? { value: domain, label: punycode(domain) }+ ? {+ value: domain,+ label: punycode(domain),+ }: null}setSelected={(option) => {@@ -288,7 +271,9 @@ export const ShortLinkInputNew = forwardRef<shortcutHint="D"buttonProps={{className: cn(- "min-w-24 sm:min-w-32 h-full rounded-r-none border-r-0 justify-start px-2.5",+ "w-32 sm:w-40 h-full rounded-r-none border-r-transparent justify-start px-2.5",+ "data-[state=open]:ring-1 data-[state=open]:ring-gray-500 data-[state=open]:border-gray-500",+ "focus:ring-1 focus:ring-gray-500 focus:border-gray-500 transition-none",!key && "text-gray-600",),}}@@ -326,6 +311,7 @@ export const ShortLinkInputNew = forwardRef<autoCapitalize="none"className={cn("block w-full rounded-r-md border-gray-300 text-gray-900 placeholder-gray-400 focus:border-gray-500 focus:outline-none focus:ring-gray-500 sm:text-sm",+ "z-0 focus:z-[1]",{"border-red-300 pr-10 text-red-900 placeholder-red-300 focus:border-red-500 focus:ring-red-500":error,diff --git a/apps/web/ui/modals/link-builder/targeting-modal.tsx b/apps/web/ui/modals/link-builder/targeting-modal.tsxindex 8641bc287f..acf7a553d1 100644--- a/apps/web/ui/modals/link-builder/targeting-modal.tsx+++ b/apps/web/ui/modals/link-builder/targeting-modal.tsx@@ -131,59 +131,63 @@ function TargetingModal({</div><div className="mt-2">{geo && (- <div className="mb-2 grid grid-cols-[min-content_1fr_min-content] gap-y-2">+ <div className="relative mb-2 grid grid-cols-[min-content_1fr_min-content] gap-y-2">{Object.entries(geo).map(([key, value]) => (<Fragment key={key}>- <Combobox- selected={{ value: key, label: COUNTRIES[key] }}- setSelected={(option) => {- if (!option) return;- const newGeo = {};- delete Object.assign(newGeo, geo, {- [option.value]: value,- })[key];- setValue("geo", newGeo, { shouldDirty: true });- }}- options={Object.entries(COUNTRIES)- .filter(- ([ck]) =>- ck === key || !Object.keys(geo).includes(ck),- )- .map(([key, value]) => ({- icon: (+ <div className="z-[1]">+ <Combobox+ selected={{ value: key, label: COUNTRIES[key] }}+ setSelected={(option) => {+ if (!option) return;+ const newGeo = {};+ delete Object.assign(newGeo, geo, {+ [option.value]: value,+ })[key];+ setValue("geo", newGeo, { shouldDirty: true });+ }}+ options={Object.entries(COUNTRIES)+ .filter(+ ([ck]) =>+ ck === key || !Object.keys(geo).includes(ck),+ )+ .map(([key, value]) => ({+ icon: (+ <img+ alt={value}+ src={`https://flag.vercel.app/m/${key}.svg`}+ className="mr-1 h-2.5 w-4"+ />+ ),+ value: key,+ label: value,+ }))}+ icon={+ key ? (<img- alt={value}+ alt={COUNTRIES[key]}src={`https://flag.vercel.app/m/${key}.svg`}- className="mr-1 h-2.5 w-4"+ className="h-2.5 w-4"/>+ ) : undefined+ }+ caret={true}+ placeholder="Country"+ searchPlaceholder="Search countries..."+ buttonProps={{+ className: cn(+ "w-32 sm:w-40 rounded-r-none border-r-transparent justify-start px-2.5",+ "data-[state=open]:ring-1 data-[state=open]:ring-gray-500 data-[state=open]:border-gray-500",+ "focus:ring-1 focus:ring-gray-500 focus:border-gray-500 transition-none",+ !key && "text-gray-600",),- value: key,- label: value,- }))}- icon={- key ? (- <img- alt={COUNTRIES[key]}- src={`https://flag.vercel.app/m/${key}.svg`}- className="h-2.5 w-4"- />- ) : undefined- }- caret={true}- placeholder="Country"- searchPlaceholder="Search countries..."- buttonProps={{- className: cn(- "w-32 sm:w-40 rounded-r-none border-r-0 justify-start px-2.5",- !key && "text-gray-600",- ),- }}- />+ }}+ />+ </div><inputtype="text"id={`${id}-${key}`}placeholder="https://example.com"- className="h-full grow rounded-r-md border border-gray-300 text-sm placeholder-gray-400 focus:border-gray-500 focus:ring-gray-500"+ className="z-0 h-full grow rounded-r-md border border-gray-300 text-sm placeholder-gray-400 focus:z-[1] focus:border-gray-500 focus:ring-gray-500"value={value}onChange={(e) => {setValue(diff --git a/packages/ui/src/combobox/index.tsx b/packages/ui/src/combobox/index.tsxindex aa727ad902..9c444353ed 100644--- a/packages/ui/src/combobox/index.tsx+++ b/packages/ui/src/combobox/index.tsx@@ -276,7 +276,7 @@ export function Combobox({</div>{caret && (<ChevronDown- className={`size-4 shrink-0 text-gray-400 transition-transform duration-75 group-data-[state=open]:rotate-180`}+ className={`ml-1 size-4 shrink-0 text-gray-400 transition-transform duration-75 group-data-[state=open]:rotate-180`}/>)}</>