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

How to collapse the side navigation bar on purpose? #59

Open
andreydung opened this issue Apr 22, 2020 · 1 comment
Open

How to collapse the side navigation bar on purpose? #59

andreydung opened this issue Apr 22, 2020 · 1 comment

Comments

@andreydung
Copy link

How could I collapse the navigation bar on purpose? I want it to collapse after each selection, i.e. if you choose Home the sidebar should minimize right away.

I tried the following:

                            onSelect={(selected) => {
                                const to = '/' + selected;
                                if (location.pathname !== to) {
                                    history.push(to);
                                }
                                this.setState({ expanded: false });

But it does not work yet.

@dscarlin
Copy link

dscarlin commented May 3, 2020

From what I can tell, the state inside the sidebar gets updated on click of the toggle; but does not update on componentDidUpdate from props changing. It would be great if that were added. You can achieve what you are looking for by putting app.js inside of your router so that whenever a new url is pushed to props.history the whole page re-renders which clears the state of the sidebar. Not the best solution but this could achieve what you are looking to do.

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

No branches or pull requests

2 participants