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

Linking the states of nested dock instances #532

Open
zhengminhui opened this issue Feb 28, 2024 · 3 comments
Open

Linking the states of nested dock instances #532

zhengminhui opened this issue Feb 28, 2024 · 3 comments
Labels
question Further information is requested

Comments

@zhengminhui
Copy link

Describe the bug
When we dynamically add a panel inside a nested dockview, it cannot save to local storage.

To Reproduce
Please check this codesandbox.
https://codesandbox.io/p/sandbox/save-state-with-nested-dock-ggqrlm?file=%2Fsrc%2Fapp.tsx%3A46%2C11-46%2C33

Steps to reproduce the behavior:

  1. First reset the layout to default status.
  2. Click on 'Add nested panel'
  3. Click on 'add a sub nested panel' inside the nested panel
  4. Click on 'Save layout'.
  5. Refresh page.

Expected behavior
'sub-panel-in-the-nested-did-not-save' should be created after refreshing page.

Screenshots
Screenshot 2024-02-28 at 4 32 14 PM

Could you take a look at this issue, please? Thanks.

@zhengminhui
Copy link
Author

I guess the problem is because when we create a nested dockview, it will create a new API instance. However when we save the state by calling toJson we just handled the parent/container API. But I'm not sure how to merge/combine these apis into one and save to localstorage.

@mathuo
Copy link
Owner

mathuo commented Feb 29, 2024

By creating another dock within the panel of an existing dock you are creating a new instance of the dock component. They are not linked internally in any way and do not know about each other.

Currently it is expected that the if the user creates a nested dock they save that nested dock state seperately and use their application state (perhaps associate that nested layout with the id of the panel it's nested within) to link everything back together. Think of the nested dock JSON as just some application state you would associate with that panel within your application.

I will leave the issue open for discussion though.

@mathuo mathuo added the question Further information is requested label Feb 29, 2024
@mathuo mathuo changed the title Cannot persistant state with nested dockview Linking the states of nested dock instances Feb 29, 2024
@zhengminhui
Copy link
Author

Thanks for your confirmation. Now I save and re-read them separately under different localstorage keys and it works fine.
The reason I asked at first is because I'm not sure if the API instances are isolated or like a tree structure.

Thank you very much and I really like your library.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants