Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PanelStack totally broken after 3.17.2 #3875

Closed
sgarnotel opened this issue Dec 3, 2019 · 2 comments · Fixed by #3879
Closed

PanelStack totally broken after 3.17.2 #3875

sgarnotel opened this issue Dec 3, 2019 · 2 comments · Fixed by #3879

Comments

@sgarnotel
Copy link

Environment

  • Package version(s): @blueprintjs/[email protected] - npm 6.13.1 - node 13.2.0
  • Browser and OS versions: Chromium Version 78.0.3904.108 (Build officiel) Arch Linux (64 bits)

Steps to reproduce

  1. Build a component with PanelStack
<div className="Panel">
     <PanelStack
        className="Panel-stack"
        stack={this.state.panels}
        onOpen={(panel) => this.handleOpen(panel)}
        onClose={this.handleClose}
     />
 </div>

The state element this.state.panels contains only one element
2. Update this.state.panels keeping the same title, component (update just props)

The PanelStack is not updated

Actual behavior

With @blueprintjs/[email protected], there is no update

Expected behavior

Same behavior of @blueprintjs/[email protected]

Possible solution

I thing PR #3787 is part of the problem, but reverse this commit is not enough

@sgarnotel
Copy link
Author

After tests, the problem is the PR #3787

Doing that and recompile with the version 3.22.0 works as expected

public componentDidUpdate(prevProps: IPanelStackProps, _prevState: IPanelStackState, _snapshot: {}) {
        super.componentDidUpdate(prevProps, _prevState, _snapshot);
        // 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(),
        //     });
        // }
        if (this.props.stack !== prevProps.stack && prevProps.stack != null) {
            this.setState({
                direction: prevProps.stack.length - this.props.stack.length < 0 ? "push" : "pop",
                stack: this.props.stack.slice().reverse(),
            });
        }
    }

@marvinsum
Copy link
Contributor

I see the issue now. I guess the fix would be to always update the local stack whenever this.props.stack changes, but only update the animate direction when the stack length changes.

@marvinsum marvinsum mentioned this issue Dec 5, 2019
2 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants