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.

Fix tag matching issue in TagsSection component

Kiran Kb09a6bf070f1
diff --git a/apps/web/ui/modals/add-edit-link-modal/tags-section.tsx b/apps/web/ui/modals/add-edit-link-modal/tags-section.tsx
index 93e90ab08b..eb98787527 100644
--- a/apps/web/ui/modals/add-edit-link-modal/tags-section.tsx
+++ b/apps/web/ui/modals/add-edit-link-modal/tags-section.tsx
@@ -36,6 +36,9 @@ export default function TagsSection({
} = useWorkspace();
const [suggestedTags, setSuggestedTags] = useState<TagProps[]>([]);
+ const tagMatch = availableTags
+ ?.map(({ name }) => name)
+ .includes(inputValue.trim());
const { complete } = useCompletion({
api: `/api/ai/completion?workspaceId=${workspaceId}`,
@@ -166,11 +169,14 @@ export default function TagsSection({
);
};
- const tagMatch = availableTags?.map(({ name }) => name).includes(inputValue);
-
return (
<div className="border-b border-gray-200 pb-2">
- <Command ref={commandRef} className="relative" loop>
+ <Command
+ ref={commandRef}
+ className="relative"
+ loop
+ filter={(value, search) => (value.includes(search.trim()) ? 1 : 0)}
+ >
<div className="group rounded-md border border-gray-300 bg-white p-1 focus-within:border-gray-500 focus-within:ring-1 focus-within:ring-gray-500">
<div className="absolute inset-y-0 left-0 flex items-center justify-center pl-3 text-gray-400">
{creatingTag ? (
@@ -217,6 +223,20 @@ export default function TagsSection({
Start typing to create tag...
</p>
)}
+ <Command.Empty>
+ {inputValue.length > 0 && (
+ <button
+ type="button"
+ onClick={() => createTag(inputValue)}
+ className="flex w-full cursor-pointer items-center rounded-md bg-gray-100 px-4 py-2 text-sm text-gray-900 hover:text-gray-900 aria-selected:bg-gray-100 aria-selected:text-gray-900"
+ >
+ Create tag{" "}
+ <span className="ml-1.5 rounded-md bg-gray-200 px-2 py-0.5 text-gray-800">
+ {inputValue}
+ </span>
+ </button>
+ )}
+ </Command.Empty>
{availableTags?.map((tag) => (
<Command.Item
key={tag.id}