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

Enhance onDidLayoutChange Behavior #520

Open
sachnk opened this issue Feb 21, 2024 · 1 comment
Open

Enhance onDidLayoutChange Behavior #520

sachnk opened this issue Feb 21, 2024 · 1 comment
Labels
enhancement New feature or request question Further information is requested

Comments

@sachnk
Copy link
Contributor

sachnk commented Feb 21, 2024

Is your feature request related to a problem? Please describe.
I'm using the onDidLayoutChange change from DockviewApi to detect changes in my layout so I can persist the layout to a database. When the onDidLayoutChange event is fired, I enable a button in my UI to save it. Otherwise, this button is hidden.

It looks like onDidLayoutChange gets fired even when the layout itself hasn't necessarily changed, but the active panel has. The result is that the user gets many spurious calls-to-action to save their layout, even though the only thing that's changed is which panel is currently active.

Is there a way to disambiguate a change in the panel that's currently active vs. an actual physical layout change, where a physical layout change would be a change in dimension, location, etc.

Describe the solution you'd like
It would be great if there was a way to disambiguate the active panel changing vs. a physical layout change. Possible solutions:

  1. Pass a parameter to onDidLayoutChange that describes the nature of the layout change, i.e. a flag indicating whether it's just a active panel change, and/or dimension/location change, etc.

  2. Change the conditions of when onDidLayoutChange is fired to ignore active panel change, and add a new onDidActivePanelChange event for capturing changes in the active panel.

I think option (1) might be preferable because it maintains more backwards compatibility with the existing behavior.

Describe alternatives you've considered
Couldn't find a suitable workaround. Maybe one exists and I've overlooked it?

Additional context
None.

@mathuo
Copy link
Owner

mathuo commented Feb 29, 2024

In version 1.10.0 several enhanements have been make to the events dockview fires, reducing duplicate events substancially. You can find a good demo of that here https://dockview.dev/demo

In terms of active panel changes, the active panel is stored as a part of the layout object and is therefore changing an active panel will trigger a layoutChange event.

Could you checkout the latest version / demo and let me know what issues you may still see?

I will also take a look at flags for the layout events.

@mathuo mathuo added question Further information is requested enhancement New feature or request labels Feb 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants