From 66e5d413b2a0523528dfdf56a66069b5843711b7 Mon Sep 17 00:00:00 2001 From: George Desipris <73396808+desiprisg@users.noreply.github.com> Date: Mon, 18 Nov 2024 12:15:06 +0200 Subject: [PATCH] fix(dashboard): Hide typed tag when it's suggested (#7039) --- apps/dashboard/src/components/primitives/popover.tsx | 6 +++--- .../dashboard/src/components/primitives/tag-input.tsx | 11 ++++++----- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/apps/dashboard/src/components/primitives/popover.tsx b/apps/dashboard/src/components/primitives/popover.tsx index 589405a32ea..5544d06ddef 100644 --- a/apps/dashboard/src/components/primitives/popover.tsx +++ b/apps/dashboard/src/components/primitives/popover.tsx @@ -1,5 +1,5 @@ -import * as React from 'react'; import * as PopoverPrimitive from '@radix-ui/react-popover'; +import * as React from 'react'; import { cn } from '@/utils/ui'; @@ -23,7 +23,7 @@ const PopoverContent = React.forwardRef< align={align} sideOffset={sideOffset} className={cn( - `bg-background text-foreground-950 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 z-50 min-w-72 rounded-md border p-4 shadow-md outline-none ${arrowClipPathClassName}`, + `bg-background text-foreground-950 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 z-50 min-w-72 overflow-auto rounded-md border p-4 shadow-md outline-none ${arrowClipPathClassName}`, className )} {...props} @@ -48,4 +48,4 @@ const PopoverArrow = React.forwardRef< PopoverContent.displayName = PopoverPrimitive.Content.displayName; -export { Popover, PopoverTrigger, PopoverContent, PopoverArrow, PopoverAnchor, PopoverPortal }; +export { Popover, PopoverAnchor, PopoverArrow, PopoverContent, PopoverPortal, PopoverTrigger }; diff --git a/apps/dashboard/src/components/primitives/tag-input.tsx b/apps/dashboard/src/components/primitives/tag-input.tsx index e403655c932..2e0a1a67c04 100644 --- a/apps/dashboard/src/components/primitives/tag-input.tsx +++ b/apps/dashboard/src/components/primitives/tag-input.tsx @@ -1,13 +1,13 @@ 'use client'; import { Badge } from '@/components/primitives/badge'; -import { Popover, PopoverAnchor, PopoverContent } from '@/components/primitives/popover'; import { CommandGroup, CommandInput, CommandItem, CommandList } from '@/components/primitives/command'; +import { inputVariants } from '@/components/primitives/input'; +import { Popover, PopoverAnchor, PopoverContent } from '@/components/primitives/popover'; import { cn } from '@/utils/ui'; import { Command } from 'cmdk'; import { forwardRef, useEffect, useMemo, useState } from 'react'; import { RiCloseFill } from 'react-icons/ri'; -import { inputVariants } from '@/components/primitives/input'; type TagInputProps = React.InputHTMLAttributes & { value: string[]; @@ -54,7 +54,7 @@ const TagInput = forwardRef((props, ref) => { return ( - +
((props, ref) => { {(validSuggestions.length > 0 || inputValue !== '') && ( { e.preventDefault(); @@ -96,12 +96,13 @@ const TagInput = forwardRef((props, ref) => { onInteractOutside={(e) => e.preventDefault()} > - {inputValue !== '' && ( + {inputValue !== '' && !validSuggestions.includes(inputValue) && ( { addTag(inputValue); }} + className="gap-1" disabled={inputValue === '' || tags.includes(inputValue)} > {inputValue}