Skip to content

Commit

Permalink
Fix PanelStack
Browse files Browse the repository at this point in the history
  • Loading branch information
marvinsum committed Dec 5, 2019
1 parent c2f9cfc commit 715a308
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions packages/core/src/components/panel-stack/panelStack.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -76,14 +76,17 @@ export class PanelStack extends AbstractPureComponent2<IPanelStackProps, IPanelS

public componentDidUpdate(prevProps: IPanelStackProps, _prevState: IPanelStackState, _snapshot: {}) {
super.componentDidUpdate(prevProps, _prevState, _snapshot);

// Always update local stack if stack prop changes
if (this.props.stack !== prevProps.stack && prevProps.stack != null) {
this.setState({ stack: this.props.stack.slice().reverse() });
}

// Only update animation direction if stack length changes
const stackLength = this.props.stack != null ? this.props.stack.length : 0;
const prevStackLength = prevProps.stack != null ? prevProps.stack.length : 0;

if (stackLength !== prevStackLength && prevProps.stack != null) {
this.setState({
direction: prevProps.stack.length - this.props.stack.length < 0 ? "push" : "pop",
stack: this.props.stack.slice().reverse(),
});
this.setState({ direction: prevProps.stack.length - this.props.stack.length < 0 ? "push" : "pop" });
}
}

Expand Down

1 comment on commit 715a308

@blueprint-bot
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fix PanelStack

Previews: documentation | landing | table

Please sign in to comment.