Skip to content

Commit

Permalink
bug: only dispose of ref group if empty
Browse files Browse the repository at this point in the history
  • Loading branch information
mathuo committed Dec 19, 2024
1 parent 684b059 commit dd91829
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -4867,6 +4867,51 @@ describe('dockviewComponent', () => {
);
});

test('move popout group of 1 panel inside grid', 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' },
});

await dockview.addPopoutGroup(panel2);

panel2.api.moveTo({ position: 'top', group: panel3.group });

expect(dockview.panels.length).toBe(3);
expect(dockview.groups.length).toBe(3);
});

test('add a popout group', async () => {
const container = document.createElement('div');

Expand Down
2 changes: 1 addition & 1 deletion packages/dockview-core/src/dockview/dockviewComponent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1885,7 +1885,7 @@ export class DockviewComponent
const refGroup = selectedGroup.referenceGroup
? this.getPanel(selectedGroup.referenceGroup)
: undefined;
if (refGroup) {
if (refGroup && refGroup.panels.length === 0) {
this.removeGroup(refGroup);
}
}
Expand Down

0 comments on commit dd91829

Please sign in to comment.