dockview icon indicating copy to clipboard operation
dockview copied to clipboard

Panel floating (last panel in group) and group floating result in same visual outcome but trigger different events (panel floating fails to fire events)

Open hllshiro opened this issue 3 weeks ago • 1 comments
trafficstars

Describe the bug
When using shift + leftclick to drag and float a panel (specifically the last panel in a group) versus floating the entire group, both operations visually result in the group being floated. However, there is a critical discrepancy in event triggering:

  • Floating the entire group triggers multiple expected events.
  • Floating the last panel in a group (which destroys the original group under the hood) fails to trigger any events—even dockviewApi.onDidRemoveGroup (which should fire when the original group is destroyed).

To Reproduce

  1. Set up a dockview with at least one group containing multiple panels (ensure the group has more than 1 panel initially).
  2. Test group floating:
    • Hover over the group's title bar.
    • Hold shift and left-click + drag the group to float it.
    • Observe that relevant events (e.g., group floating events, potential group movement events) are triggered.
  3. Test last panel floating:
    • In the same group, hover over the last panel's title bar.
    • Hold shift and left-click + drag the last panel to float it (this visually floats the group but destroys the original group under the hood).
    • Check event listeners (e.g., dockviewApi.onDidRemoveGroup, floating-related events) and confirm no events are triggered.
  const group = api.addGroup({
    id: 'main',
    direction: 'right',
  })
  group.api.onActiveChange(event => {
    console.log('[onActiveChange]', event)
  })
  group.api.onDidActiveChange(event => {
    console.log('[onDidActiveChange]', event)
  })
  group.api.onDidActivePanelChange(event => {
    console.log('[onDidActivePanelChange]', event)
  })
  group.api.onDidConstraintsChange(event => {
    console.log('[onDidConstraintsChange]', event)
  })
  group.api.onDidFocusChange(event => {
    console.log('[onDidFocusChange]', event)
  })
  group.api.onDidLocationChange(event => {
    console.log('[onDidLocationChange]', event)
  })
  group.api.onDidParametersChange(event => {
    console.log('[onDidParametersChange]', event)
  })
  group.api.onDidSizeChange(event => {
    console.log('[onDidSizeChange]', event)
  })
  group.api.onDidVisibilityChange(event => {
    console.log('[onDidVisibilityChange]', event)
  })
  group.api.onWillFocus(event => {
    console.log('[onWillFocus]', event)
  })
  api.onDidRemoveGroup(event => {
    console.log('[onDidRemoveGroup]', event)
  })
  api.addPanel({
    id: 'test',
    component: 'Test',
    position: {
      referenceGroup: group,
      direction: 'within',
    },
  })

Expected behavior
While the underlying mechanisms differ (group floating preserves the original group; last panel floating destroys it), both operations should trigger appropriate events:

  • Group floating should continue triggering its current set of events.
  • Last panel floating (which destroys the original group) should trigger dockviewApi.onDidRemoveGroup (for the destroyed group) and other relevant events (e.g., panel floating events).

Screenshots

  • float group

https://github.com/user-attachments/assets/c612d0b5-304d-4a74-be4f-5ce73b698423

  • float panel

https://github.com/user-attachments/assets/1b83f962-8e72-463a-81af-4ba9fec11724

Desktop (please complete the following information):

  • Browser: Chrome
  • Version: 130+

Additional context
Under the hood, floating the last panel in a group destroys the original group, while floating the group itself does not. This difference in behavior should be reflected in event triggering (especially for group removal), but currently, the last panel floating operation fails to emit any events. This issue prevents me from accurately tracking all groups, which will lead to some problems.

hllshiro avatar Oct 30 '25 08:10 hllshiro

It bears some similarity to #753, but not exactly the same. I aim to keep all groups under my control, ensuring the new panel loads in the expected group.

We’d better intercept the group prior to closing, and hide it instead. Re-adding the group afterward won’t ensure it’s created in the same location.

Just like the scenario shown in the diagram below:

init

Image

close or float panel no.8 then re-add

Image Image

hllshiro avatar Oct 30 '25 08:10 hllshiro