forked from vergnet/application-amicale
Fixed accordion auto closing on setting selection
This commit is contained in:
parent
cb522466c7
commit
517e75f4b9
1 changed files with 4 additions and 4 deletions
|
@ -12,7 +12,7 @@ type Props = {
|
||||||
title: string,
|
title: string,
|
||||||
subtitle?: string,
|
subtitle?: string,
|
||||||
left?: (props: { [keys: string]: any }) => React.Node,
|
left?: (props: { [keys: string]: any }) => React.Node,
|
||||||
opened: boolean,
|
opened?: boolean,
|
||||||
unmountWhenCollapsed: boolean,
|
unmountWhenCollapsed: boolean,
|
||||||
children?: React.Node,
|
children?: React.Node,
|
||||||
}
|
}
|
||||||
|
@ -26,7 +26,6 @@ const AnimatedListIcon = Animatable.createAnimatableComponent(List.Icon);
|
||||||
class AnimatedAccordion extends React.Component<Props, State> {
|
class AnimatedAccordion extends React.Component<Props, State> {
|
||||||
|
|
||||||
static defaultProps = {
|
static defaultProps = {
|
||||||
opened: false,
|
|
||||||
unmountWhenCollapsed: false,
|
unmountWhenCollapsed: false,
|
||||||
}
|
}
|
||||||
chevronRef: { current: null | AnimatedListIcon };
|
chevronRef: { current: null | AnimatedListIcon };
|
||||||
|
@ -35,7 +34,7 @@ class AnimatedAccordion extends React.Component<Props, State> {
|
||||||
animEnd: string;
|
animEnd: string;
|
||||||
|
|
||||||
state = {
|
state = {
|
||||||
expanded: this.props.opened,
|
expanded: this.props.opened != null ? this.props.opened : false,
|
||||||
}
|
}
|
||||||
|
|
||||||
constructor(props) {
|
constructor(props) {
|
||||||
|
@ -63,7 +62,8 @@ class AnimatedAccordion extends React.Component<Props, State> {
|
||||||
};
|
};
|
||||||
|
|
||||||
shouldComponentUpdate(nextProps: Props) {
|
shouldComponentUpdate(nextProps: Props) {
|
||||||
this.state.expanded = nextProps.opened;
|
if (nextProps.opened != null)
|
||||||
|
this.state.expanded = nextProps.opened;
|
||||||
this.setupChevron();
|
this.setupChevron();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue