Skip to content

Commit 680eaca

Browse files
authored
Merge pull request #824 from mathuo/797-popout-group-flow-error-1
bug: fix floating->popout->floating group transition
2 parents c7c1ae9 + c6865c6 commit 680eaca

File tree

2 files changed

+86
-0
lines changed

2 files changed

+86
-0
lines changed

packages/dockview-core/src/__tests__/dockview/dockviewComponent.spec.ts

+72
Original file line numberDiff line numberDiff line change
@@ -5021,6 +5021,78 @@ describe('dockviewComponent', () => {
50215021
expect(panel3.api.location.type).toBe('grid');
50225022
});
50235023

5024+
test('grid -> floating -> popout -> floating', async () => {
5025+
const container = document.createElement('div');
5026+
5027+
window.open = () => setupMockWindow();
5028+
5029+
const dockview = new DockviewComponent(container, {
5030+
createComponent(options) {
5031+
switch (options.name) {
5032+
case 'default':
5033+
return new PanelContentPartTest(
5034+
options.id,
5035+
options.name
5036+
);
5037+
default:
5038+
throw new Error(`unsupported`);
5039+
}
5040+
},
5041+
});
5042+
5043+
dockview.layout(1000, 500);
5044+
5045+
const panel1 = dockview.addPanel({
5046+
id: 'panel_1',
5047+
component: 'default',
5048+
});
5049+
5050+
const panel2 = dockview.addPanel({
5051+
id: 'panel_2',
5052+
component: 'default',
5053+
});
5054+
5055+
const panel3 = dockview.addPanel({
5056+
id: 'panel_3',
5057+
component: 'default',
5058+
position: { direction: 'right' },
5059+
});
5060+
5061+
expect(panel1.api.location.type).toBe('grid');
5062+
expect(panel2.api.location.type).toBe('grid');
5063+
expect(panel3.api.location.type).toBe('grid');
5064+
5065+
dockview.addFloatingGroup(panel2.group);
5066+
5067+
expect(panel1.api.location.type).toBe('floating');
5068+
expect(panel2.api.location.type).toBe('floating');
5069+
expect(panel3.api.location.type).toBe('grid');
5070+
5071+
await dockview.addPopoutGroup(panel2.group);
5072+
5073+
expect(panel1.api.location.type).toBe('popout');
5074+
expect(panel2.api.location.type).toBe('popout');
5075+
expect(panel3.api.location.type).toBe('grid');
5076+
5077+
dockview.addFloatingGroup(panel2.group);
5078+
5079+
expect(panel1.api.location.type).toBe('floating');
5080+
expect(panel2.api.location.type).toBe('floating');
5081+
expect(panel3.api.location.type).toBe('grid');
5082+
5083+
await dockview.addPopoutGroup(panel2.group);
5084+
5085+
expect(panel1.api.location.type).toBe('popout');
5086+
expect(panel2.api.location.type).toBe('popout');
5087+
expect(panel3.api.location.type).toBe('grid');
5088+
5089+
panel2.group.api.moveTo({ group: panel3.group });
5090+
5091+
expect(panel1.api.location.type).toBe('grid');
5092+
expect(panel2.api.location.type).toBe('grid');
5093+
expect(panel3.api.location.type).toBe('grid');
5094+
});
5095+
50245096
test('that panel is rendered when moving from popout to new group', async () => {
50255097
const container = document.createElement('div');
50265098

packages/dockview-core/src/dockview/dockviewComponent.ts

+14
Original file line numberDiff line numberDiff line change
@@ -846,6 +846,20 @@ export class DockviewComponent
846846
this.overlayRenderContainer;
847847
returnedGroup = group;
848848

849+
const alreadyRemoved = !this._popoutGroups.find(
850+
(p) => p.popoutGroup === group
851+
);
852+
853+
if (alreadyRemoved) {
854+
/**
855+
* If this popout group was explicitly removed then we shouldn't run the additional
856+
* steps. To tell if the running of this disposable is the result of this popout group
857+
* being explicitly removed we can check if this popout group is still referenced in
858+
* the `this._popoutGroups` list.
859+
*/
860+
return;
861+
}
862+
849863
if (floatingBox) {
850864
this.addFloatingGroup(group, {
851865
height: floatingBox.height,

0 commit comments

Comments
 (0)