dockview icon indicating copy to clipboard operation
dockview copied to clipboard

Floating panel event listeners

Open ericsvendsen opened this issue 1 year ago • 4 comments

Is your feature request related to a problem? Please describe. I'm trying to implement a UI using floating panels. One requirement is for the panels' positions to persist when the page is refreshed. Currently this is not possible because there are no event listeners available for when a floating panel is moved or closed.

Describe the solution you'd like Expose event listeners for when a floating panel is moved or closed.

Describe alternatives you've considered Currently I'm using the SerializedDockview to get panel position, and I've hidden the close button by using a custom tab component. I'm using external controls to add/remove panels, and before that occurs I store the panel's position in local storage. This works fine when hiding/showing the panels with my external controls, but moving a panel and then refreshing the page results in losing the latest position data.

ericsvendsen avatar Nov 04 '24 02:11 ericsvendsen

I could expose an event api.onDidRepositionFloatingGroup if that helps?

image

mathuo avatar Nov 04 '24 20:11 mathuo

As long as that includes the top, right, bottom, and left data that would be great! Would that also fire when a panel/group is closed?

ericsvendsen avatar Nov 04 '24 21:11 ericsvendsen

In regards to the panel/group closing is there a reason why you couldn't use api.onDidRemoveGroup / api.onDidRemovePanel?

Also of of interest what is the reason you require the top, right, bottom, left data? Are you persisting your layout without using the built-in api.toJSON() and api.fromJSON() methods?

mathuo avatar Nov 10 '24 10:11 mathuo

In regards to the panel/group closing is there a reason why you couldn't use api.onDidRemoveGroup / api.onDidRemovePanel?

This does appear to do what I need, however the position value in the fromJSON method is strange when I call it in this event handler. For some reason, bottom and right are required according to Typescript, but they're not always provided in the JSON returned from that method. The resulting discrepancy yields unpredictable results when trying to restore panel positions. I don't think this is something isolated to this event. It's just where I notice it happening. Idk, I'm probably misunderstanding something though.

Also of of interest what is the reason you require the top, right, bottom, left data? Are you persisting your layout without using the built-in api.toJSON() and api.fromJSON() methods?

Because once a panel is closed, it's gone. I need a reference to closed panels, so when I need to open it again, it can appear in the same spot it was in when it was closed. It would actually be a lot easier if you could define panels and then just toggle their visibility rather than removing/adding them completely.

ericsvendsen avatar Nov 16 '24 04:11 ericsvendsen