mirror of
https://github.com/mathuo/dockview
synced 2025-05-03 10:08:24 +00:00
bug: ghost groups appearing
This commit is contained in:
parent
87f257df1e
commit
a82aac09bc
@ -272,6 +272,59 @@ describe('dockviewComponent', () => {
|
||||
});
|
||||
|
||||
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', () => {
|
||||
dockview = new DockviewComponent(container, {
|
||||
createComponent(options) {
|
||||
|
@ -2332,31 +2332,33 @@ export class DockviewComponent
|
||||
}
|
||||
}
|
||||
|
||||
const referenceLocation = getGridLocation(to.element);
|
||||
const dropLocation = getRelativeLocation(
|
||||
this.gridview.orientation,
|
||||
referenceLocation,
|
||||
target
|
||||
);
|
||||
if (from.api.location.type !== 'popout') {
|
||||
const referenceLocation = getGridLocation(to.element);
|
||||
const dropLocation = getRelativeLocation(
|
||||
this.gridview.orientation,
|
||||
referenceLocation,
|
||||
target
|
||||
);
|
||||
|
||||
let size: number;
|
||||
let size: number;
|
||||
|
||||
switch (this.gridview.orientation) {
|
||||
case Orientation.VERTICAL:
|
||||
size =
|
||||
referenceLocation.length % 2 == 0
|
||||
? from.api.width
|
||||
: from.api.height;
|
||||
break;
|
||||
case Orientation.HORIZONTAL:
|
||||
size =
|
||||
referenceLocation.length % 2 == 0
|
||||
? from.api.height
|
||||
: from.api.width;
|
||||
break;
|
||||
switch (this.gridview.orientation) {
|
||||
case Orientation.VERTICAL:
|
||||
size =
|
||||
referenceLocation.length % 2 == 0
|
||||
? from.api.width
|
||||
: from.api.height;
|
||||
break;
|
||||
case Orientation.HORIZONTAL:
|
||||
size =
|
||||
referenceLocation.length % 2 == 0
|
||||
? from.api.height
|
||||
: from.api.width;
|
||||
break;
|
||||
}
|
||||
|
||||
this.gridview.addView(from, size, dropLocation);
|
||||
}
|
||||
|
||||
this.gridview.addView(from, size, dropLocation);
|
||||
}
|
||||
|
||||
from.panels.forEach((panel) => {
|
||||
|
Loading…
Reference in New Issue
Block a user