bug: fix floating->popout->floating group transition

This commit is contained in:
mathuo 2025-01-09 20:38:42 +00:00
parent 872ec7cba9
commit c6865c691c
No known key found for this signature in database
GPG Key ID: C6EEDEFD6CA07281
2 changed files with 86 additions and 0 deletions

View File

@ -5021,6 +5021,78 @@ describe('dockviewComponent', () => {
expect(panel3.api.location.type).toBe('grid');
});
test('grid -> floating -> popout -> floating', async () => {
const container = document.createElement('div');
window.open = () => setupMockWindow();
const dockview = new DockviewComponent(container, {
createComponent(options) {
switch (options.name) {
case 'default':
return new PanelContentPartTest(
options.id,
options.name
);
default:
throw new Error(`unsupported`);
}
},
});
dockview.layout(1000, 500);
const panel1 = dockview.addPanel({
id: 'panel_1',
component: 'default',
});
const panel2 = dockview.addPanel({
id: 'panel_2',
component: 'default',
});
const panel3 = dockview.addPanel({
id: 'panel_3',
component: 'default',
position: { direction: 'right' },
});
expect(panel1.api.location.type).toBe('grid');
expect(panel2.api.location.type).toBe('grid');
expect(panel3.api.location.type).toBe('grid');
dockview.addFloatingGroup(panel2.group);
expect(panel1.api.location.type).toBe('floating');
expect(panel2.api.location.type).toBe('floating');
expect(panel3.api.location.type).toBe('grid');
await dockview.addPopoutGroup(panel2.group);
expect(panel1.api.location.type).toBe('popout');
expect(panel2.api.location.type).toBe('popout');
expect(panel3.api.location.type).toBe('grid');
dockview.addFloatingGroup(panel2.group);
expect(panel1.api.location.type).toBe('floating');
expect(panel2.api.location.type).toBe('floating');
expect(panel3.api.location.type).toBe('grid');
await dockview.addPopoutGroup(panel2.group);
expect(panel1.api.location.type).toBe('popout');
expect(panel2.api.location.type).toBe('popout');
expect(panel3.api.location.type).toBe('grid');
panel2.group.api.moveTo({ group: panel3.group });
expect(panel1.api.location.type).toBe('grid');
expect(panel2.api.location.type).toBe('grid');
expect(panel3.api.location.type).toBe('grid');
});
test('that panel is rendered when moving from popout to new group', async () => {
const container = document.createElement('div');

View File

@ -846,6 +846,20 @@ export class DockviewComponent
this.overlayRenderContainer;
returnedGroup = group;
const alreadyRemoved = !this._popoutGroups.find(
(p) => p.popoutGroup === group
);
if (alreadyRemoved) {
/**
* If this popout group was explicitly removed then we shouldn't run the additional
* steps. To tell if the running of this disposable is the result of this popout group
* being explicitly removed we can check if this popout group is still referenced in
* the `this._popoutGroups` list.
*/
return;
}
if (floatingBox) {
this.addFloatingGroup(group, {
height: floatingBox.height,