chore: use constant

This commit is contained in:
mathuo 2025-08-11 20:35:19 +01:00
parent 0a19313cc7
commit 874d6a27ca
No known key found for this signature in database
GPG Key ID: C6EEDEFD6CA07281
2 changed files with 18 additions and 15 deletions

View File

@ -1,3 +1,5 @@
export const DEFAULT_FLOATING_GROUP_OVERFLOW_SIZE = 100;
export const DEFAULT_FLOATING_GROUP_POSITION = { left: 100, top: 100, width: 300, height: 300 };
export const DESERIALIZATION_POPOUT_DELAY_MS = 100

View File

@ -70,6 +70,7 @@ import { AnchoredBox, AnchorPosition, Box } from '../types';
import {
DEFAULT_FLOATING_GROUP_OVERFLOW_SIZE,
DEFAULT_FLOATING_GROUP_POSITION,
DESERIALIZATION_POPOUT_DELAY_MS,
} from '../constants';
import {
DockviewPanelRenderer,
@ -1533,7 +1534,7 @@ export class DockviewComponent
// Create a promise that resolves when all popout groups are created
const popoutPromises: Promise<void>[] = [];
// Queue popup group creation with delays to avoid browser blocking
serializedPopoutGroups.forEach((serializedPopoutGroup, index) => {
const { data, position, gridReferenceGroup, url } =
@ -1553,12 +1554,12 @@ export class DockviewComponent
popoutUrl: url,
});
resolve();
}, index * 100); // 100ms delay between each popup
}, index * DESERIALIZATION_POPOUT_DELAY_MS); // 100ms delay between each popup
});
popoutPromises.push(popoutPromise);
});
// Store the promise for tests to wait on
this._popoutRestorationPromise = Promise.all(popoutPromises).then(() => void 0);
@ -2382,8 +2383,8 @@ export class DockviewComponent
}
} else if (targetActivePanel) {
// Ensure the target group's original active panel remains active
to.model.openPanel(targetActivePanel, {
skipSetGroupActive: true
to.model.openPanel(targetActivePanel, {
skipSetGroupActive: true
});
}
} else {
@ -2408,13 +2409,13 @@ export class DockviewComponent
if (!selectedPopoutGroup) {
throw new Error('failed to find popout group');
}
// Remove from popout groups list to prevent automatic restoration
const index = this._popoutGroups.indexOf(selectedPopoutGroup);
if (index >= 0) {
this._popoutGroups.splice(index, 1);
}
// Clean up the reference group (ghost) if it exists and is hidden
if (selectedPopoutGroup.referenceGroup) {
const referenceGroup = this.getPanel(selectedPopoutGroup.referenceGroup);
@ -2422,10 +2423,10 @@ export class DockviewComponent
this.doRemoveGroup(referenceGroup, { skipActive: true });
}
}
// Manually dispose the window without triggering restoration
selectedPopoutGroup.window.dispose();
// Update group's location and containers for target
if (to.api.location.type === 'grid') {
from.model.renderContainer = this.overlayRenderContainer;
@ -2436,7 +2437,7 @@ export class DockviewComponent
from.model.dropTargetContainer = this.rootDropTargetContainer;
from.model.location = { type: 'floating' };
}
break;
}
}
@ -2449,7 +2450,7 @@ export class DockviewComponent
referenceLocation,
target
);
// Add to grid for all moves targeting grid location
let size: number;
@ -2478,7 +2479,7 @@ export class DockviewComponent
);
if (targetFloatingGroup) {
const box = targetFloatingGroup.overlay.toJSON();
// Calculate position based on available properties
let left: number, top: number;
if ('left' in box) {
@ -2488,7 +2489,7 @@ export class DockviewComponent
} else {
left = 50; // Default fallback
}
if ('top' in box) {
top = box.top + 50;
} else if ('bottom' in box) {
@ -2496,7 +2497,7 @@ export class DockviewComponent
} else {
top = 50; // Default fallback
}
this.addFloatingGroup(from, {
height: box.height,
width: box.width,