mathuo / dockview

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

When I was using this project, I encountered three tricky issues #636

Open zhanghengwebs opened 3 months ago

zhanghengwebs commented 3 months ago

Firstly, I added a panel and then deleted it, but I need to display it again. However, when it is displayed again, its position changes. Is there any way to make it return to its original position?

  1. When I drag and drop two tab panels within a group, there are no events to listen to their changes, so when I refresh the page, the sub panels will return to their original positions
  2. I have a requirement that elements within a specific group (including the current entire group) cannot be dragged into other groups. Can a similar feature be provided
mathuo commented 3 months ago
  1. Not too sure what you mean here, how are you removing and adding the panel? Do you have a small code snippet?

  2. has a current open issue with pending PR https://github.com/mathuo/dockview/issues/582

  3. should already be posible using the onWillShowOverlay event, I will try and create an example to demonstrate.

lupod commented 3 months ago

Regarding 1.) I think I have the same issue. I have a toolbar where you can show/hide several different tool windows. There is one toggle button for each registered component. When enabling a button, a panel for that component is added to the layout using addPanel. When disabling a button, the panel is removed via removePanel (also tried panel.api.close(), same behaviour).

The problem occurs after hiding a panel that is the only panel inside its group. If you then add the panel again, it appears at a different position compared to where it was when it was hidden. However, when it is not the only panel in the group when it is hidden, then adding it again places it back into the group.

I think the enhancement would be for each panel to "remember" where it was when it was removed so it can be added back with a position and size as close as possible to what it had when it was hidden. Currently this only works when the original group still exists. I can imagine the difficult part is that the layout could have changed in between and guessing the "as close as possible" layout could be challenging. The impact on UX would be IMHO quite significant though when using a toolbar to manage visible panels.

zhanghengwebs commented 3 months ago
  1. Not too sure what you mean here, how are you removing and adding the panel? Do you have a small code snippet?
  2. has a current open issue with pending PR Expose event for moving tab within same panel #582
  3. should already be posible using the onWillShowOverlay event, I will try and create an example to demonstrate.

Currently, the panel positions are declared during registration. For example, panel B is located to the right of panel A, and panel C is located to the right of panel B. When I delete panels A, B, and C in sequence and generate C, B, and A in reverse order, their positions are different from before deletion, even if I do not change any registration properties because when C is registered, B no longer exists.

  1. Another issue is that I have two panels, A and B. A serves as my main panel, and in the future, I will add some sub panels to this group. However, when I delete A and register A again, I cannot add sub panels to A. I found that the groupId has changed, so I cannot continue to add sub panels to it. Therefore, I have to save the newly generated groupId locally every time and then map it

If you check whether you have registered before when registering the panel, and if the same ID is used, then continue to use the original one, can this solve the problem

We look forward to your reply