Skip to content

Commit

Permalink
fix: correctly apply styles to <Select> icon (#4026)
Browse files Browse the repository at this point in the history
  • Loading branch information
sebald authored Jul 19, 2024
1 parent 0e58fe6 commit 94e9a1b
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 2 deletions.
5 changes: 5 additions & 0 deletions .changeset/lucky-plums-fix.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@marigold/components": patch
---

fix: correctly apply styles to `<Select>` icon
19 changes: 18 additions & 1 deletion packages/components/src/Select/Select.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ const theme: Theme = {
size: { small: 'text-sm' },
},
}),
icon: cva(),
icon: cva('text-zinc-600'),
},
Underlay: cva(),
ListBox: {
Expand Down Expand Up @@ -407,6 +407,23 @@ test('supports styling classnames with variants and sizes from theme', () => {
expect(button.className).toContain('text-sm');
});

test('supports applying styles to the caret icon', () => {
render(
<Select label="Label" data-testid="select">
<Select.Section>
<Select.Option id="one">one</Select.Option>
<Select.Option id="two">two</Select.Option>
</Select.Section>
</Select>
);

const button = screen.getByRole('button');
// eslint-disable-next-line testing-library/no-node-access
const icon = button.querySelector('svg');

expect(icon).toHaveClass('text-zinc-600');
});

test('set width via props', () => {
render(
<Select label="Label" data-testid="select" width="1/2">
Expand Down
2 changes: 1 addition & 1 deletion packages/components/src/Select/Select.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ const _Select = forwardRef<any, SelectProps<object>>(
)}
>
<SelectValue />
<ChevronDown className="size-4" />
<ChevronDown className={cn('size-4', classNames.icon)} />
</Button>
<Popover>
<ListBox items={items}>{props.children}</ListBox>
Expand Down

0 comments on commit 94e9a1b

Please sign in to comment.