mathuo / dockview

Zero dependency Docking Layout Manager. Supports Vanilla TypeScript, React and Vue.
https://dockview.dev
MIT License
738 stars 52 forks source link

Unable to persist fullscreen / maximized mode #494

Open garyvh2 opened 9 months ago

garyvh2 commented 9 months ago

Describe the bug Fullscreen (or maximized) state, is not persisted when calling api.toJSON. Instead this.exitMaximizedView(); is called modifying the end users state.

To Reproduce Codesandbox example

https://github.com/mathuo/dockview/assets/21265830/25e8f289-fa7b-4296-9d87-daed56e58d5c

Whenever there's a call to onDidLayoutChange we persist the user's layout state, with toJSON() so we store the layout structure on our end.

When we added the Maximize feature we noticed that the when the user maximizes the group, and changes the active tab, the call to toJSON() executed on onDidLayoutChange causes the maximize state to be lost.

Upon closer inspection on the library we noticed that

dockviewComponent.ts ln.1010 -> this.gridview.serialize() // When the gridview is serialized
   |__ gridview.ts ln.439 -> this.exitMaximizedView() // The library exits the maximized view purposely

Additionally we noticed the comment on

gridview.ts ln.435
/**
 * do not persist maximized view state
 * firstly exit any maximized views to ensure the correct dimensions are persisted
 */

And were wondering if there was a reason for such, we on our end wanted to persist the maximized state, as it's originated from a user interaction, so forcefully removing state is thought as a non expected behavior, but not sure if there was a deeper reason as to not persist such state on your end.

Expected behavior When the layout is persisted through toJSON method, the maximized state is persisted along the other components.

Screenshots N/A

Desktop (please complete the following information):

gggonzalo commented 9 months ago

This issue is even more evident when the group is maximized but the visible panel is not active. If you click anywhere in the maximized panel (inactive), onDidLayoutChange gets triggered and the maximized state is exited.

https://github.com/mathuo/dockview/assets/118962418/59eb2a77-2ee4-46ca-b8bc-ab1da4a1d969

mathuo commented 9 months ago

This issue is even more evident when the group is maximized but the visible panel is not active. If you click anywhere in the maximized panel (inactive), onDidLayoutChange gets triggered and the maximized state is exited.

Screen.Recording.2024-02-08.at.16.00.42.mov

This particular issue has been fixed in v1.10.0 - when a group is maximized it's automatically set as the active group

mathuo commented 9 months ago

As for the fullscreen state not being persisted - it would require some non-trival code changes to get to work due the fact of having to store extra metadata in the persisted state.

I agree it's a feature that should exist and will look into it at some point in the near future.

gggonzalo commented 2 weeks ago

Hi @mathuo. Is there an update on the maximized state persistence issue? I see v2.0.0. was released recently

mathuo commented 2 weeks ago

Let me move this up the priority list since it's clearly a wanted feature. I will take a look, recorded here https://github.com/mathuo/dockview/issues/756