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

Floating panel event listeners #753

Open
ericsvendsen opened this issue Nov 4, 2024 · 4 comments · May be fixed by #754
Open

Floating panel event listeners #753

ericsvendsen opened this issue Nov 4, 2024 · 4 comments · May be fixed by #754
Milestone

Comments

@ericsvendsen
Copy link

ericsvendsen commented Nov 4, 2024

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.

@mathuo
Copy link
Owner

mathuo commented Nov 4, 2024

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

image

@mathuo mathuo linked a pull request Nov 4, 2024 that will close this issue
@mathuo mathuo added this to the v2.1.0 milestone Nov 4, 2024
@ericsvendsen
Copy link
Author

ericsvendsen commented Nov 4, 2024

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?

@mathuo
Copy link
Owner

mathuo commented Nov 10, 2024

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?

@ericsvendsen
Copy link
Author

ericsvendsen commented Nov 16, 2024

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.

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

Successfully merging a pull request may close this issue.

2 participants