Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bug: fix floating->popout->floating group transition #824

Merged
merged 1 commit into from
Jan 11, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -5021,6 +5021,78 @@ describe('dockviewComponent', () => {
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 () => {
const container = document.createElement('div');

Expand Down
14 changes: 14 additions & 0 deletions packages/dockview-core/src/dockview/dockviewComponent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -846,6 +846,20 @@ export class DockviewComponent
this.overlayRenderContainer;
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) {
this.addFloatingGroup(group, {
height: floatingBox.height,
Expand Down
Loading