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 doesn't allow shifted panel components to keep their state #3667

Closed
jayphelps opened this issue Jul 19, 2019 · 3 comments · Fixed by #3768
Closed

PanelStack doesn't allow shifted panel components to keep their state #3667

jayphelps opened this issue Jul 19, 2019 · 3 comments · Fixed by #3768

Comments

@jayphelps
Copy link

jayphelps commented Jul 19, 2019

Feature request

Right now it appears that pushing a new panel on the stack causes the previously active panel to no longer be rendered which, because of the way React works, means it loses any internal state it has. When you navigate back/pop you'll get the old panel component back, but without any state it had built up. In many use cases this is problematic.

This would presumably be a breaking change, unless opt-in via some sort of flag e.g. keepPanelState: true

Demo: https://stackblitz.com/edit/react-fzveef?file=index.js

@adidahiya
Copy link
Contributor

I suppose we could support a rendering setup similar to how the Tabs component handles renderActiveTabPanelOnly... yes it should be added as an opt-in feature with a flag... something like

/**
 * If false, PanelStack will render all panels in the stack to the DOM, allowing their React component trees to maintain state as a user navigates through the stack. Panels other than the currently active one will be invisible.
 * @default true
 */
renderCurrentPanelOnly?: boolean;

@vdhanan
Copy link

vdhanan commented Aug 4, 2019

@adidahiya I'd like to work on this if no one's already opened a PR

@adidahiya
Copy link
Contributor

@vdhanan feel free, as with any issue marked "help wanted"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants