Skip to content

Commit 9ee36ef

Browse files
committed
fixed a minor bug for auto expansion on edit method button
1 parent 2e841ee commit 9ee36ef

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

src/AccordionExpansionContext.tsx

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,13 @@ export const AccordionExpansionProvider: React.FC<{ children: ReactNode }> = ({
3030
};
3131

3232
const expandMethodAndParent = (parentId: string, methodId: string) => {
33-
// Ensure both parent and method are expanded
34-
setExpandedMethod(prev => prev === methodId ? null : methodId);
35-
setExpandedParent(prev => prev === parentId ? null : parentId);
33+
// Ensure method is toggled (expand/collapse)
34+
setExpandedMethod(prev => (prev === methodId ? null : methodId));
35+
36+
// Only set the parent if it's different from the current parent
37+
setExpandedParent(prev => (prev === parentId ? prev : parentId));
3638
};
39+
3740

3841
return (
3942
<AccordionExpansionContext.Provider

0 commit comments

Comments
 (0)