From 517e75f4b9a3f7051b9ced93670df1eb8d4e2c1f Mon Sep 17 00:00:00 2001 From: Arnaud Vergnet Date: Fri, 1 May 2020 11:10:26 +0200 Subject: [PATCH] Fixed accordion auto closing on setting selection --- src/components/Animations/AnimatedAccordion.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/components/Animations/AnimatedAccordion.js b/src/components/Animations/AnimatedAccordion.js index 9c4fc79..c113ad1 100644 --- a/src/components/Animations/AnimatedAccordion.js +++ b/src/components/Animations/AnimatedAccordion.js @@ -12,7 +12,7 @@ type Props = { title: string, subtitle?: string, left?: (props: { [keys: string]: any }) => React.Node, - opened: boolean, + opened?: boolean, unmountWhenCollapsed: boolean, children?: React.Node, } @@ -26,7 +26,6 @@ const AnimatedListIcon = Animatable.createAnimatableComponent(List.Icon); class AnimatedAccordion extends React.Component { static defaultProps = { - opened: false, unmountWhenCollapsed: false, } chevronRef: { current: null | AnimatedListIcon }; @@ -35,7 +34,7 @@ class AnimatedAccordion extends React.Component { animEnd: string; state = { - expanded: this.props.opened, + expanded: this.props.opened != null ? this.props.opened : false, } constructor(props) { @@ -63,7 +62,8 @@ class AnimatedAccordion extends React.Component { }; shouldComponentUpdate(nextProps: Props) { - this.state.expanded = nextProps.opened; + if (nextProps.opened != null) + this.state.expanded = nextProps.opened; this.setupChevron(); return true; }