Return popouts whn blocked by browser

This commit is contained in:
Mathias Borglin 2025-05-09 10:15:24 +02:00
parent 477bf14767
commit 809b7665f5
2 changed files with 33 additions and 16 deletions

View File

@ -251,6 +251,9 @@ export class Tabs extends CompositeDisposable {
delete(id: string): void {
const index = this.indexOf(id);
const tabToRemove = this._tabs.splice(index, 1)[0];
if (!tabToRemove) {
return;
}
const { value, disposable } = tabToRemove;

View File

@ -718,27 +718,11 @@ export class DockviewComponent
return false;
}
if (popoutContainer === null) {
popoutWindowDisposable.dispose();
this._onDidBlockPopout.fire();
return false;
}
const gready = document.createElement('div');
gready.className = 'dv-overlay-render-container';
const overlayRenderContainer = new OverlayRenderContainer(
gready,
this
);
const referenceGroup =
itemToPopout instanceof DockviewPanel
? itemToPopout.group
: itemToPopout;
const referenceLocation = itemToPopout.api.location.type;
/**
* The group that is being added doesn't already exist within the DOM, the most likely occurrence
* of this case is when being called from the `fromJSON(...)` method
@ -757,6 +741,36 @@ export class DockviewComponent
this._onDidAddGroup.fire(group);
}
if (popoutContainer === null) {
popoutWindowDisposable.dispose();
this._onDidBlockPopout.fire();
// if the popout window was blocked, we need to move the group back to the reference group
// and set it to visible
this.movingLock(() =>
moveGroupWithoutDestroying({
from: group,
to: referenceGroup,
})
);
if (!referenceGroup.api.isVisible) {
referenceGroup.api.setVisible(true);
}
return false;
}
const gready = document.createElement('div');
gready.className = 'dv-overlay-render-container';
const overlayRenderContainer = new OverlayRenderContainer(
gready,
this
);
const referenceLocation = itemToPopout.api.location.type;
group.model.renderContainer = overlayRenderContainer;
group.layout(
_window.window!.innerWidth,