mirror of
https://github.com/mathuo/dockview
synced 2025-08-18 07:06:02 +00:00
bug: ghost groups appearing
This commit is contained in:
parent
87f257df1e
commit
a82aac09bc
@ -272,6 +272,59 @@ describe('dockviewComponent', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
describe('move group', () => {
|
describe('move group', () => {
|
||||||
|
test('that moving a popup group into the grid manages view disposals correctly', async () => {
|
||||||
|
window.open = () => setupMockWindow();
|
||||||
|
|
||||||
|
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(600, 1000);
|
||||||
|
|
||||||
|
const panel1 = dockview.addPanel({
|
||||||
|
id: 'panel1',
|
||||||
|
component: 'default',
|
||||||
|
});
|
||||||
|
const panel2 = dockview.addPanel({
|
||||||
|
id: 'panel2',
|
||||||
|
component: 'default',
|
||||||
|
position: { direction: 'right' },
|
||||||
|
});
|
||||||
|
const panel3 = dockview.addPanel({
|
||||||
|
id: 'panel3',
|
||||||
|
component: 'default',
|
||||||
|
position: { direction: 'right' },
|
||||||
|
});
|
||||||
|
|
||||||
|
await dockview.addPopoutGroup(panel1.api.group);
|
||||||
|
|
||||||
|
expect(panel1.api.location.type).toBe('popout');
|
||||||
|
expect(dockview.groups.length).toBe(4);
|
||||||
|
expect(dockview.panels.length).toBe(3);
|
||||||
|
|
||||||
|
panel1.api.group.api.moveTo({
|
||||||
|
group: panel2.api.group,
|
||||||
|
position: 'left',
|
||||||
|
});
|
||||||
|
|
||||||
|
expect(panel1.api.location.type).toBe('grid');
|
||||||
|
expect(dockview.groups.length).toBe(3);
|
||||||
|
expect(dockview.panels.length).toBe(3);
|
||||||
|
|
||||||
|
const query = dockview.element.querySelectorAll('.dv-view');
|
||||||
|
expect(query.length).toBe(3);
|
||||||
|
});
|
||||||
|
|
||||||
test('horizontal', () => {
|
test('horizontal', () => {
|
||||||
dockview = new DockviewComponent(container, {
|
dockview = new DockviewComponent(container, {
|
||||||
createComponent(options) {
|
createComponent(options) {
|
||||||
|
@ -2332,31 +2332,33 @@ export class DockviewComponent
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const referenceLocation = getGridLocation(to.element);
|
if (from.api.location.type !== 'popout') {
|
||||||
const dropLocation = getRelativeLocation(
|
const referenceLocation = getGridLocation(to.element);
|
||||||
this.gridview.orientation,
|
const dropLocation = getRelativeLocation(
|
||||||
referenceLocation,
|
this.gridview.orientation,
|
||||||
target
|
referenceLocation,
|
||||||
);
|
target
|
||||||
|
);
|
||||||
|
|
||||||
let size: number;
|
let size: number;
|
||||||
|
|
||||||
switch (this.gridview.orientation) {
|
switch (this.gridview.orientation) {
|
||||||
case Orientation.VERTICAL:
|
case Orientation.VERTICAL:
|
||||||
size =
|
size =
|
||||||
referenceLocation.length % 2 == 0
|
referenceLocation.length % 2 == 0
|
||||||
? from.api.width
|
? from.api.width
|
||||||
: from.api.height;
|
: from.api.height;
|
||||||
break;
|
break;
|
||||||
case Orientation.HORIZONTAL:
|
case Orientation.HORIZONTAL:
|
||||||
size =
|
size =
|
||||||
referenceLocation.length % 2 == 0
|
referenceLocation.length % 2 == 0
|
||||||
? from.api.height
|
? from.api.height
|
||||||
: from.api.width;
|
: from.api.width;
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
this.gridview.addView(from, size, dropLocation);
|
||||||
}
|
}
|
||||||
|
|
||||||
this.gridview.addView(from, size, dropLocation);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
from.panels.forEach((panel) => {
|
from.panels.forEach((panel) => {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user