diff --git a/packages/core/src/components/collapse/collapse.tsx b/packages/core/src/components/collapse/collapse.tsx index faaf49d634..daaa818368 100644 --- a/packages/core/src/components/collapse/collapse.tsx +++ b/packages/core/src/components/collapse/collapse.tsx @@ -104,13 +104,8 @@ export enum AnimationStates { CLOSED, } -export interface ICollapseSnapshot { - animationState?: AnimationStates; - height?: string; -} - @polyfill -export class Collapse extends AbstractPureComponent2 { +export class Collapse extends AbstractPureComponent2 { public static displayName = `${DISPLAYNAME_PREFIX}.Collapse`; public static defaultProps: ICollapseProps = { @@ -120,6 +115,35 @@ export class Collapse extends AbstractPureComponent2 this.setState({ animationState: AnimationStates.CLOSING, height: "0px", }), ); - this.setTimeout(() => this.onDelayedStateChange(), this.props.transitionDuration); - } - if (snapshot.animationState === AnimationStates.OPEN_START) { + this.setTimeout(() => this.onDelayedStateChange(), transitionDuration); + } else if (animationState === AnimationStates.OPEN_START) { this.setState({ animationState: AnimationStates.OPENING, - height: this.height + "px", + height: height !== undefined ? `${height}px` : this.state.height, }); - this.setTimeout(() => this.onDelayedStateChange(), this.props.transitionDuration); + this.setTimeout(() => this.onDelayedStateChange(), transitionDuration); } } private contentsRefHandler = (el: HTMLElement) => { this.contents = el; if (el != null) { - this.height = this.contents.clientHeight; this.setState({ animationState: this.props.isOpen ? AnimationStates.OPEN : AnimationStates.CLOSED, - height: `${this.height}px`, + height: `${this.contents.clientHeight}px`, }); } };