Unverified Commit 59468d72 authored by Max Schmitt's avatar Max Schmitt Committed by GitHub
Browse files

fix(AccordionToggle): default button type=button (#5076)

parent e87744eb
......@@ -25,7 +25,7 @@ export function useAccordionToggle(eventKey, onClick) {
const onSelect = useContext(SelectableContext);
return (e) => {
/*
/*
Compare the event key in context with the given event key.
If they are the same, then collapse the component.
*/
......@@ -50,6 +50,10 @@ const AccordionToggle = React.forwardRef(
) => {
const accordionOnClick = useAccordionToggle(eventKey, onClick);
if (Component === 'button') {
props.type = 'button';
}
return (
<Component ref={ref} onClick={accordionOnClick} {...props}>
{children}
......
......@@ -5,6 +5,8 @@ import AccordionToggle from '../src/AccordionToggle';
describe('<AccordionToggle>', () => {
it('Should have button as default component', () => {
mount(<AccordionToggle eventKey="" />).assertSingle('button');
mount(<AccordionToggle eventKey="" />).assertSingle(
'button[type="button"]',
);
});
});
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment