Skip to content

Commit

Permalink
fix(core): update picklist and select components to handle long text …
Browse files Browse the repository at this point in the history
…in placeholder
  • Loading branch information
bc-alexsaiannyi committed Aug 8, 2024
1 parent 1ef848c commit caa3777
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ export const Picklist = ({
? onChange
: validateAgainstMissingValue
}
placeholder={field.choosePrefix}
placeholder={<span className="truncate">{field.choosePrefix}</span>}
required={field.isRequired}
variant={isValid === false ? 'error' : undefined}
>
Expand Down
9 changes: 6 additions & 3 deletions core/components/ui/select/select.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import * as SelectPrimitive from '@radix-ui/react-select';
import { cva } from 'class-variance-authority';
import { Check, ChevronDown, ChevronDownIcon, ChevronUpIcon } from 'lucide-react';
import { ComponentPropsWithRef, ElementRef, forwardRef } from 'react';
import { ComponentPropsWithRef, ElementRef, forwardRef, ReactNode } from 'react';

import { cn } from '~/lib/utils';

Expand All @@ -24,7 +24,7 @@ type SelectTriggerType = typeof SelectPrimitive.Trigger;

interface SelectProps extends ComponentPropsWithRef<SelectType> {
variant?: 'success' | 'error';
placeholder?: string;
placeholder?: string | ReactNode;
className?: string;
'aria-label'?: string;
id?: string;
Expand All @@ -40,7 +40,10 @@ const Select = forwardRef<ElementRef<SelectTriggerType>, SelectProps>(
id={id}
ref={ref}
>
<SelectPrimitive.Value placeholder={placeholder} />
<SelectPrimitive.Value
asChild={typeof placeholder !== 'string'}
placeholder={placeholder}
/>
<SelectPrimitive.Icon>
<ChevronDown className="inline group-focus-visible:text-primary group-enabled:group-hover:text-primary" />
</SelectPrimitive.Icon>
Expand Down

0 comments on commit caa3777

Please sign in to comment.