mirror of
https://github.com/mathuo/dockview
synced 2025-02-09 01:45:45 +00:00
Merge pull request #824 from mathuo/797-popout-group-flow-error-1
bug: fix floating->popout->floating group transition
This commit is contained in:
commit
680eaca96c
@ -5021,6 +5021,78 @@ describe('dockviewComponent', () => {
|
|||||||
expect(panel3.api.location.type).toBe('grid');
|
expect(panel3.api.location.type).toBe('grid');
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test('grid -> floating -> popout -> floating', 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' },
|
||||||
|
});
|
||||||
|
|
||||||
|
expect(panel1.api.location.type).toBe('grid');
|
||||||
|
expect(panel2.api.location.type).toBe('grid');
|
||||||
|
expect(panel3.api.location.type).toBe('grid');
|
||||||
|
|
||||||
|
dockview.addFloatingGroup(panel2.group);
|
||||||
|
|
||||||
|
expect(panel1.api.location.type).toBe('floating');
|
||||||
|
expect(panel2.api.location.type).toBe('floating');
|
||||||
|
expect(panel3.api.location.type).toBe('grid');
|
||||||
|
|
||||||
|
await dockview.addPopoutGroup(panel2.group);
|
||||||
|
|
||||||
|
expect(panel1.api.location.type).toBe('popout');
|
||||||
|
expect(panel2.api.location.type).toBe('popout');
|
||||||
|
expect(panel3.api.location.type).toBe('grid');
|
||||||
|
|
||||||
|
dockview.addFloatingGroup(panel2.group);
|
||||||
|
|
||||||
|
expect(panel1.api.location.type).toBe('floating');
|
||||||
|
expect(panel2.api.location.type).toBe('floating');
|
||||||
|
expect(panel3.api.location.type).toBe('grid');
|
||||||
|
|
||||||
|
await dockview.addPopoutGroup(panel2.group);
|
||||||
|
|
||||||
|
expect(panel1.api.location.type).toBe('popout');
|
||||||
|
expect(panel2.api.location.type).toBe('popout');
|
||||||
|
expect(panel3.api.location.type).toBe('grid');
|
||||||
|
|
||||||
|
panel2.group.api.moveTo({ group: panel3.group });
|
||||||
|
|
||||||
|
expect(panel1.api.location.type).toBe('grid');
|
||||||
|
expect(panel2.api.location.type).toBe('grid');
|
||||||
|
expect(panel3.api.location.type).toBe('grid');
|
||||||
|
});
|
||||||
|
|
||||||
test('that panel is rendered when moving from popout to new group', async () => {
|
test('that panel is rendered when moving from popout to new group', async () => {
|
||||||
const container = document.createElement('div');
|
const container = document.createElement('div');
|
||||||
|
|
||||||
|
@ -846,6 +846,20 @@ export class DockviewComponent
|
|||||||
this.overlayRenderContainer;
|
this.overlayRenderContainer;
|
||||||
returnedGroup = group;
|
returnedGroup = group;
|
||||||
|
|
||||||
|
const alreadyRemoved = !this._popoutGroups.find(
|
||||||
|
(p) => p.popoutGroup === group
|
||||||
|
);
|
||||||
|
|
||||||
|
if (alreadyRemoved) {
|
||||||
|
/**
|
||||||
|
* If this popout group was explicitly removed then we shouldn't run the additional
|
||||||
|
* steps. To tell if the running of this disposable is the result of this popout group
|
||||||
|
* being explicitly removed we can check if this popout group is still referenced in
|
||||||
|
* the `this._popoutGroups` list.
|
||||||
|
*/
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (floatingBox) {
|
if (floatingBox) {
|
||||||
this.addFloatingGroup(group, {
|
this.addFloatingGroup(group, {
|
||||||
height: floatingBox.height,
|
height: floatingBox.height,
|
||||||
|
Loading…
Reference in New Issue
Block a user