Skip to content

Commit 974c126

Browse files
fix(dropdown): add type button in dropdown (#757)
* fix(dropdown): add type button in dropdown fix #756 * test(dropdown): add test of type button in dropdown component
1 parent 89d58dc commit 974c126

File tree

2 files changed

+18
-4
lines changed

2 files changed

+18
-4
lines changed

src/lib/components/Dropdown/Dropdown.spec.tsx

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,10 +55,24 @@ describe('Components / Dropdown', () => {
5555
expect(dropdown()).not.toHaveClass('invisible');
5656
});
5757
});
58+
describe('Type of button', async () => {
59+
it('should be of type `button`', async () => {
60+
render(<TestDropdown />);
61+
expect(button()).toHaveAttribute('type', 'button');
62+
});
63+
64+
it('should be of type `button` with inline', async () => {
65+
render(<TestDropdown inline />);
66+
expect(button()).toHaveAttribute('type', 'button');
67+
});
68+
});
5869
});
5970

60-
const TestDropdown: FC<{ dismissOnClick?: boolean }> = ({ dismissOnClick = true }) => (
61-
<Dropdown label="Dropdown button" placement="right" dismissOnClick={dismissOnClick}>
71+
const TestDropdown: FC<{ dismissOnClick?: boolean; inline?: boolean }> = ({
72+
dismissOnClick = true,
73+
inline = false,
74+
}) => (
75+
<Dropdown label="Dropdown button" placement="right" dismissOnClick={dismissOnClick} inline={inline}>
6276
<Dropdown.Header>
6377
<span className="block text-sm">Bonnie Green</span>
6478
<span className="block truncate text-sm font-medium">[email protected]</span>

src/lib/components/Dropdown/Dropdown.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -119,11 +119,11 @@ const DropdownComponent: FC<DropdownProps> = ({
119119
}, [ref]);
120120

121121
return inline ? (
122-
<button ref={ref} className={theme.inlineWrapper}>
122+
<button type="button" ref={ref} className={theme.inlineWrapper}>
123123
{children}
124124
</button>
125125
) : (
126-
<Button ref={ref} {...buttonProps}>
126+
<Button type="button" ref={ref} {...buttonProps}>
127127
{children}
128128
</Button>
129129
);

0 commit comments

Comments
 (0)