mirror of
https://github.com/mathuo/dockview
synced 2025-03-10 16:02:04 +00:00
Merge pull request #598 from mathuo/596-moving-a-group-leaves-ghost-groups-that-cant-be-removed
bug: duplicate group added when added group with absolute position
This commit is contained in:
commit
87d42c96e2
@ -5331,4 +5331,48 @@ describe('dockviewComponent', () => {
|
||||
expect(addGroupCount).toBe(2);
|
||||
});
|
||||
});
|
||||
|
||||
test('addGroup with absolute position', () => {
|
||||
const container = document.createElement('div');
|
||||
|
||||
const dockview = new DockviewComponent({
|
||||
parentElement: container,
|
||||
createComponent(options) {
|
||||
switch (options.name) {
|
||||
case 'default':
|
||||
return new PanelContentPartTest(
|
||||
options.id,
|
||||
options.name
|
||||
);
|
||||
default:
|
||||
throw new Error(`unsupported`);
|
||||
}
|
||||
},
|
||||
});
|
||||
const api = new DockviewApi(dockview);
|
||||
|
||||
dockview.layout(1000, 1000);
|
||||
|
||||
api.addPanel({
|
||||
id: 'panel_1',
|
||||
component: 'default',
|
||||
});
|
||||
api.addPanel({
|
||||
id: 'panel_2',
|
||||
component: 'default',
|
||||
});
|
||||
const panel3 = api.addPanel({
|
||||
id: 'panel_3',
|
||||
component: 'default',
|
||||
position: { direction: 'right' },
|
||||
});
|
||||
|
||||
expect(api.panels.length).toBe(3);
|
||||
expect(api.groups.length).toBe(2);
|
||||
|
||||
api.addGroup({direction:'left'});
|
||||
|
||||
expect(api.panels.length).toBe(3);
|
||||
expect(api.groups.length).toBe(3);
|
||||
});
|
||||
});
|
||||
|
@ -1620,8 +1620,6 @@ export class DockviewComponent
|
||||
}
|
||||
|
||||
addGroup(options?: AddGroupOptions): DockviewGroupPanel {
|
||||
const group = this.createGroup(options);
|
||||
|
||||
if (options) {
|
||||
let referenceGroup: DockviewGroupPanel | undefined;
|
||||
|
||||
@ -1675,12 +1673,16 @@ export class DockviewComponent
|
||||
location,
|
||||
target
|
||||
);
|
||||
|
||||
const group = this.createGroup(options);
|
||||
this.doAddGroup(group, relativeLocation);
|
||||
if (!options.skipSetActive) {
|
||||
this.doSetGroupAndPanelActive(group);
|
||||
}
|
||||
return group;
|
||||
} else {
|
||||
const group = this.createGroup(options);
|
||||
|
||||
this.doAddGroup(group);
|
||||
this.doSetGroupAndPanelActive(group);
|
||||
return group;
|
||||
|
Loading…
Reference in New Issue
Block a user