Skip to content

Commit

Permalink
fix(dropdown): add type button in dropdown (#757)
Browse files Browse the repository at this point in the history
* fix(dropdown): add type button in dropdown

fix #756

* test(dropdown): add test of type button in dropdown component
  • Loading branch information
lucasalberto01 authored May 22, 2023
1 parent 89d58dc commit 974c126
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 4 deletions.
18 changes: 16 additions & 2 deletions src/lib/components/Dropdown/Dropdown.spec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -55,10 +55,24 @@ describe('Components / Dropdown', () => {
expect(dropdown()).not.toHaveClass('invisible');
});
});
describe('Type of button', async () => {
it('should be of type `button`', async () => {
render(<TestDropdown />);
expect(button()).toHaveAttribute('type', 'button');
});

it('should be of type `button` with inline', async () => {
render(<TestDropdown inline />);
expect(button()).toHaveAttribute('type', 'button');
});
});
});

const TestDropdown: FC<{ dismissOnClick?: boolean }> = ({ dismissOnClick = true }) => (
<Dropdown label="Dropdown button" placement="right" dismissOnClick={dismissOnClick}>
const TestDropdown: FC<{ dismissOnClick?: boolean; inline?: boolean }> = ({
dismissOnClick = true,
inline = false,
}) => (
<Dropdown label="Dropdown button" placement="right" dismissOnClick={dismissOnClick} inline={inline}>
<Dropdown.Header>
<span className="block text-sm">Bonnie Green</span>
<span className="block truncate text-sm font-medium">[email protected]</span>
Expand Down
4 changes: 2 additions & 2 deletions src/lib/components/Dropdown/Dropdown.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -119,11 +119,11 @@ const DropdownComponent: FC<DropdownProps> = ({
}, [ref]);

return inline ? (
<button ref={ref} className={theme.inlineWrapper}>
<button type="button" ref={ref} className={theme.inlineWrapper}>
{children}
</button>
) : (
<Button ref={ref} {...buttonProps}>
<Button type="button" ref={ref} {...buttonProps}>
{children}
</Button>
);
Expand Down

0 comments on commit 974c126

Please sign in to comment.