Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions lib/components/Select/Select.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,14 @@ describe('Select', () => {

expect(option).toBeInTheDocument();
});

it('should render the labelAction next to the label', () => {
setup({
labelAction: <button type="button">Action</button>,
});

expect(screen.getByText('Action')).toBeInTheDocument();
});
});

describe('select inside a form', () => {
Expand Down
1 change: 1 addition & 0 deletions lib/components/Select/Select.types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ export type SelectProps = VariantProps<typeof selectVariants> &
isLoading?: boolean;
isRequired?: boolean;
label?: string;
labelAction?: ReactNode;
labelClassName?: string;
labelWrapperClassName?: string;
listClassName?: string;
Expand Down
9 changes: 8 additions & 1 deletion lib/components/Select/components/Wrapper.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ export const Wrapper: ForwardRefExoticComponent<
isLoading,
isRequired,
label,
labelAction,
labelClassName,
labelWrapperClassName,
listClassName,
Expand Down Expand Up @@ -135,7 +136,12 @@ export const Wrapper: ForwardRefExoticComponent<
data-theme={theme}
>
{label ? (
<div className={cn(labelWrapperClassName)}>
<div
className={cn(
'flex items-center justify-between',
labelWrapperClassName,
)}
>
<label
id={htmlFor}
className={cn(labelVariants({ className: labelClassName }))}
Expand All @@ -147,6 +153,7 @@ export const Wrapper: ForwardRefExoticComponent<
<span className="text-red-600 dark:text-red-500 ml-1">*</span>
)}
</label>
{labelAction}
</div>
) : null}

Expand Down