The modern link attribution platform. Loved by world-class engineering teams at Twilio, Zillow, Jobber, Vercel, Raycast, and more.
TypeScript clickhousemysqlnextjsopen-sourceplanetscaleprismatailwindcsstinybirdtypescriptupstashvercel
chore: improve tag selector widget with cmdk
flooorianflofa86f5afef30
diff --git a/apps/web/ui/analytics/tag-selector.tsx b/apps/web/ui/analytics/tag-selector.tsxindex 4413977161..75ff06562f 100644--- a/apps/web/ui/analytics/tag-selector.tsx+++ b/apps/web/ui/analytics/tag-selector.tsx@@ -1,5 +1,6 @@import useTags from "@/lib/swr/use-tags";import { IconMenu, Popover, Tick, useRouterStuff } from "@dub/ui";+import { Command } from "cmdk";import { ChevronDown, Search, Tag } from "lucide-react";import Link from "next/link";import { useSearchParams } from "next/navigation";@@ -26,51 +27,59 @@ export default function TagSelector() {return tags && tags.length > 0 ? (<Popovercontent={- <div className="grid w-full p-2 md:w-48">- {tags.length > 10 && (- <div className="relative mb-2">- <div className="pointer-events-none absolute inset-y-0 left-3.5 flex items-center">- <Search className="h-4 w-4 text-gray-400" />+ <Command>+ <div className="grid w-full p-2 md:w-48">+ {tags.length > 10 && (+ <div className="relative mb-2">+ <div className="pointer-events-none absolute inset-y-0 left-3.5 flex items-center">+ <Search className="h-4 w-4 text-gray-400" />+ </div>++ <Command.Input+ value={filterValue}+ autoFocus+ onValueChange={(search: string) => setFilterValue(search)}+ placeholder="Filter tags..."+ className="w-full rounded-md border border-gray-300 py-1.5 pl-10 text-black placeholder:text-gray-400 focus:border-black focus:outline-none focus:ring-gray-600 sm:text-sm"+ /></div>- <input- type="text"- value={filterValue}- onChange={(e) => setFilterValue(e.target.value)}- className="w-full rounded-md border border-gray-300 py-2 pl-10 text-black placeholder:text-gray-400 focus:border-black focus:outline-none focus:ring-gray-600 sm:text-sm"- placeholder="Filter tags..."- />- </div>- )}- <Link- href={- queryParams({- del: "tagId",- getNewPath: true,- }) as string- }- className="flex w-full items-center justify-between space-x-2 rounded-md p-2 hover:bg-gray-100 active:bg-gray-200"- >- <p className="text-sm">All tags</p>- {!selectedTagId && <Tick className="h-4 w-4" aria-hidden="true" />}- </Link>- {filteredTags.map((tag) => (- <Link- key={tag.id}- href={- queryParams({- set: { tagId: tag.id },- getNewPath: true,- }) as string- }- className="flex w-full items-center justify-between space-x-2 rounded-md p-2 hover:bg-gray-100 active:bg-gray-200"- >- <TagBadge {...tag} />- {selectedTagId === tag.id && (- <Tick className="h-4 w-4" aria-hidden="true" />- )}- </Link>- ))}- </div>+ )}+ <Command.List className="max-h-96 overflow-y-scroll">+ {/* All tags selection should be shown all the time */}+ <Link+ href={+ queryParams({+ del: "tagId",+ getNewPath: true,+ }) as string+ }+ className="flex w-full items-center justify-between space-x-2 rounded-md p-2 hover:bg-gray-100 active:bg-gray-200"+ >+ <p className="text-sm">All tags</p>+ {!selectedTagId && (+ <Tick className="h-4 w-4" aria-hidden="true" />+ )}+ </Link>+ {filteredTags.map((tag) => (+ <Link+ key={tag.id}+ href={+ queryParams({+ set: { tagId: tag.id },+ getNewPath: true,+ }) as string+ }+ className="flex w-full items-center justify-between space-x-2 rounded-md p-2 hover:bg-gray-100 active:bg-gray-200"+ >+ <TagBadge {...tag} />+ {selectedTagId === tag.id && (+ <Tick className="h-4 w-4" aria-hidden="true" />+ )}+ </Link>+ ))}+ </Command.List>+ </div>+ </Command>}openPopover={openPopover}setOpenPopover={setOpenPopover}