Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error fix in accordian #2666 issue fix #1 #2684

Open
wants to merge 9 commits into
base: master
Choose a base branch
from
4 changes: 2 additions & 2 deletions src/UncontrolledAccordion.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ const defaultProps = {
};

function UncontrolledAccordion({ defaultOpen, stayOpen, ...props }) {
const [open, setOpen] = useState(defaultOpen || (stayOpen ? [] : undefined));
const [open, setOpen] = useState(defaultOpen || (stayOpen ? [] : ''));
const toggle = (id) => {
if (stayOpen) {
if (open.includes(id)) {
Expand All @@ -31,7 +31,7 @@ function UncontrolledAccordion({ defaultOpen, stayOpen, ...props }) {
setOpen([...open, id]);
}
} else if (open === id) {
setOpen(undefined);
setOpen('');
} else {
setOpen(id);
}
Expand Down
2 changes: 1 addition & 1 deletion stories/examples/Accordion/AccordionExample.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ function Example(props) {
const [open, setOpen] = useState('1');
const toggle = (id) => {
if (open === id) {
setOpen();
setOpen('');
} else {
setOpen(id);
}
Expand Down
2 changes: 1 addition & 1 deletion stories/examples/Accordion/AccordionFlushExample.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ function Example(props) {
const [open, setOpen] = useState('');
const toggle = (id) => {
if (open === id) {
setOpen();
setOpen('');
} else {
setOpen(id);
}
Expand Down