Skip to content

Commit

Permalink
Merge pull request #796 from mathuo/795-popout-groups-bug
Browse files Browse the repository at this point in the history
bug: only dispose of ref group if empty
  • Loading branch information
mathuo authored Dec 20, 2024
2 parents 684b059 + dd91829 commit ff0bf75
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 ff0bf75

Please sign in to comment.