dockview-react 4.6.2 → 4.7.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * dockview-react
3
- * @version 4.6.2
3
+ * @version 4.7.1
4
4
  * @link https://github.com/mathuo/dockview
5
5
  * @license MIT
6
6
  */
@@ -2135,6 +2135,19 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
2135
2135
  }
2136
2136
  throw new Error('invalid node');
2137
2137
  }
2138
+ function cloneNode(node, size, orthogonalSize) {
2139
+ if (node instanceof BranchNode) {
2140
+ const result = new BranchNode(node.orientation, node.proportionalLayout, node.styles, size, orthogonalSize, node.disabled, node.margin);
2141
+ for (let i = node.children.length - 1; i >= 0; i--) {
2142
+ const child = node.children[i];
2143
+ result.addChild(cloneNode(child, child.size, child.orthogonalSize), child.size, 0, true);
2144
+ }
2145
+ return result;
2146
+ }
2147
+ else {
2148
+ return new LeafNode(node.view, node.orientation, orthogonalSize);
2149
+ }
2150
+ }
2138
2151
  function flipNode(node, size, orthogonalSize) {
2139
2152
  if (node instanceof BranchNode) {
2140
2153
  const result = new BranchNode(orthogonal(node.orientation), node.proportionalLayout, node.styles, size, orthogonalSize, node.disabled, node.margin);
@@ -2485,6 +2498,29 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
2485
2498
  this._onDidChange.fire(e);
2486
2499
  });
2487
2500
  }
2501
+ normalize() {
2502
+ if (!this._root) {
2503
+ return;
2504
+ }
2505
+ if (this._root.children.length !== 1) {
2506
+ return;
2507
+ }
2508
+ const oldRoot = this.root;
2509
+ // can remove one level of redundant branching if there is only a single child
2510
+ const childReference = oldRoot.children[0];
2511
+ if (childReference instanceof LeafNode) {
2512
+ return;
2513
+ }
2514
+ oldRoot.element.remove();
2515
+ const child = oldRoot.removeChild(0); // Remove child to prevent double disposal
2516
+ oldRoot.dispose(); // Dispose old root (won't dispose removed child)
2517
+ child.dispose(); // Dispose the removed child
2518
+ this._root = cloneNode(childReference, childReference.size, childReference.orthogonalSize);
2519
+ this.element.appendChild(this._root.element);
2520
+ this.disposable.value = this._root.onDidChange((e) => {
2521
+ this._onDidChange.fire(e);
2522
+ });
2523
+ }
2488
2524
  /**
2489
2525
  * If the root is orientated as a VERTICAL node then nest the existing root within a new HORIZIONTAL root node
2490
2526
  * If the root is orientated as a HORIZONTAL node then nest the existing root within a new VERITCAL root node
@@ -3772,9 +3808,10 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
3772
3808
  }
3773
3809
 
3774
3810
  class DragHandler extends CompositeDisposable {
3775
- constructor(el) {
3811
+ constructor(el, disabled) {
3776
3812
  super();
3777
3813
  this.el = el;
3814
+ this.disabled = disabled;
3778
3815
  this.dataDisposable = new MutableDisposable();
3779
3816
  this.pointerEventsDisposable = new MutableDisposable();
3780
3817
  this._onDragStart = new Emitter();
@@ -3782,12 +3819,15 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
3782
3819
  this.addDisposables(this._onDragStart, this.dataDisposable, this.pointerEventsDisposable);
3783
3820
  this.configure();
3784
3821
  }
3822
+ setDisabled(disabled) {
3823
+ this.disabled = disabled;
3824
+ }
3785
3825
  isCancelled(_event) {
3786
3826
  return false;
3787
3827
  }
3788
3828
  configure() {
3789
3829
  this.addDisposables(this._onDragStart, addDisposableListener(this.el, 'dragstart', (event) => {
3790
- if (event.defaultPrevented || this.isCancelled(event)) {
3830
+ if (event.defaultPrevented || this.isCancelled(event) || this.disabled) {
3791
3831
  event.preventDefault();
3792
3832
  return;
3793
3833
  }
@@ -3876,6 +3916,48 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
3876
3916
  }
3877
3917
  }
3878
3918
 
3919
+ function setGPUOptimizedBounds(element, bounds) {
3920
+ const { top, left, width, height } = bounds;
3921
+ const topPx = `${Math.round(top)}px`;
3922
+ const leftPx = `${Math.round(left)}px`;
3923
+ const widthPx = `${Math.round(width)}px`;
3924
+ const heightPx = `${Math.round(height)}px`;
3925
+ // Use traditional positioning but maintain GPU layer
3926
+ element.style.top = topPx;
3927
+ element.style.left = leftPx;
3928
+ element.style.width = widthPx;
3929
+ element.style.height = heightPx;
3930
+ element.style.visibility = 'visible';
3931
+ // Ensure GPU layer is maintained
3932
+ if (!element.style.transform || element.style.transform === '') {
3933
+ element.style.transform = 'translate3d(0, 0, 0)';
3934
+ }
3935
+ }
3936
+ function setGPUOptimizedBoundsFromStrings(element, bounds) {
3937
+ const { top, left, width, height } = bounds;
3938
+ // Use traditional positioning but maintain GPU layer
3939
+ element.style.top = top;
3940
+ element.style.left = left;
3941
+ element.style.width = width;
3942
+ element.style.height = height;
3943
+ element.style.visibility = 'visible';
3944
+ // Ensure GPU layer is maintained
3945
+ if (!element.style.transform || element.style.transform === '') {
3946
+ element.style.transform = 'translate3d(0, 0, 0)';
3947
+ }
3948
+ }
3949
+ function checkBoundsChanged(element, bounds) {
3950
+ const { top, left, width, height } = bounds;
3951
+ const topPx = `${Math.round(top)}px`;
3952
+ const leftPx = `${Math.round(left)}px`;
3953
+ const widthPx = `${Math.round(width)}px`;
3954
+ const heightPx = `${Math.round(height)}px`;
3955
+ // Check if position or size changed (back to traditional method)
3956
+ return element.style.top !== topPx ||
3957
+ element.style.left !== leftPx ||
3958
+ element.style.width !== widthPx ||
3959
+ element.style.height !== heightPx;
3960
+ }
3879
3961
  class WillShowOverlayEvent extends DockviewEvent {
3880
3962
  get nativeEvent() {
3881
3963
  return this.options.nativeEvent;
@@ -4157,21 +4239,11 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
4157
4239
  box.left = rootLeft + width - 4;
4158
4240
  box.width = 4;
4159
4241
  }
4160
- const topPx = `${Math.round(box.top)}px`;
4161
- const leftPx = `${Math.round(box.left)}px`;
4162
- const widthPx = `${Math.round(box.width)}px`;
4163
- const heightPx = `${Math.round(box.height)}px`;
4164
- if (overlay.style.top === topPx &&
4165
- overlay.style.left === leftPx &&
4166
- overlay.style.width === widthPx &&
4167
- overlay.style.height === heightPx) {
4242
+ // Use GPU-optimized bounds checking and setting
4243
+ if (!checkBoundsChanged(overlay, box)) {
4168
4244
  return;
4169
4245
  }
4170
- overlay.style.top = topPx;
4171
- overlay.style.left = leftPx;
4172
- overlay.style.width = widthPx;
4173
- overlay.style.height = heightPx;
4174
- overlay.style.visibility = 'visible';
4246
+ setGPUOptimizedBounds(overlay, box);
4175
4247
  overlay.className = `dv-drop-target-anchor${this.options.className ? ` ${this.options.className}` : ''}`;
4176
4248
  toggleClass(overlay, 'dv-drop-target-left', isLeft);
4177
4249
  toggleClass(overlay, 'dv-drop-target-right', isRight);
@@ -4223,10 +4295,7 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
4223
4295
  box.top = `${100 * (1 - size)}%`;
4224
4296
  box.height = `${100 * size}%`;
4225
4297
  }
4226
- this.overlayElement.style.top = box.top;
4227
- this.overlayElement.style.left = box.left;
4228
- this.overlayElement.style.width = box.width;
4229
- this.overlayElement.style.height = box.height;
4298
+ setGPUOptimizedBoundsFromStrings(this.overlayElement, box);
4230
4299
  toggleClass(this.overlayElement, 'dv-drop-target-small-vertical', isSmallY);
4231
4300
  toggleClass(this.overlayElement, 'dv-drop-target-small-horizontal', isSmallX);
4232
4301
  toggleClass(this.overlayElement, 'dv-drop-target-left', isLeft);
@@ -4958,8 +5027,8 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
4958
5027
  }
4959
5028
 
4960
5029
  class TabDragHandler extends DragHandler {
4961
- constructor(element, accessor, group, panel) {
4962
- super(element);
5030
+ constructor(element, accessor, group, panel, disabled) {
5031
+ super(element, disabled);
4963
5032
  this.accessor = accessor;
4964
5033
  this.group = group;
4965
5034
  this.panel = panel;
@@ -4995,7 +5064,7 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
4995
5064
  this._element.tabIndex = 0;
4996
5065
  this._element.draggable = !this.accessor.options.disableDnd;
4997
5066
  toggleClass(this.element, 'dv-inactive-tab', true);
4998
- const dragHandler = new TabDragHandler(this._element, this.accessor, this.group, this.panel);
5067
+ this.dragHandler = new TabDragHandler(this._element, this.accessor, this.group, this.panel, !!this.accessor.options.disableDnd);
4999
5068
  this.dropTarget = new Droptarget(this._element, {
5000
5069
  acceptedTargetZones: ['left', 'right'],
5001
5070
  overlayModel: { activationSize: { value: 50, type: 'percentage' } },
@@ -5012,7 +5081,7 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
5012
5081
  getOverrideTarget: () => { var _a; return (_a = group.model.dropTargetContainer) === null || _a === void 0 ? void 0 : _a.model; },
5013
5082
  });
5014
5083
  this.onWillShowOverlay = this.dropTarget.onWillShowOverlay;
5015
- this.addDisposables(this._onPointDown, this._onDropped, this._onDragStart, dragHandler.onDragStart((event) => {
5084
+ this.addDisposables(this._onPointDown, this._onDropped, this._onDragStart, this.dragHandler.onDragStart((event) => {
5016
5085
  if (event.dataTransfer) {
5017
5086
  const style = getComputedStyle(this.element);
5018
5087
  const newNode = this.element.cloneNode(true);
@@ -5024,7 +5093,7 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
5024
5093
  });
5025
5094
  }
5026
5095
  this._onDragStart.fire(event);
5027
- }), dragHandler, addDisposableListener(this._element, 'pointerdown', (event) => {
5096
+ }), this.dragHandler, addDisposableListener(this._element, 'pointerdown', (event) => {
5028
5097
  this._onPointDown.fire(event);
5029
5098
  }), this.dropTarget.onDrop((event) => {
5030
5099
  this._onDropped.fire(event);
@@ -5043,6 +5112,7 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
5043
5112
  }
5044
5113
  updateDragAndDropState() {
5045
5114
  this._element.draggable = !this.accessor.options.disableDnd;
5115
+ this.dragHandler.setDisabled(!!this.accessor.options.disableDnd);
5046
5116
  }
5047
5117
  dispose() {
5048
5118
  super.dispose();
@@ -5084,8 +5154,8 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
5084
5154
  }
5085
5155
 
5086
5156
  class GroupDragHandler extends DragHandler {
5087
- constructor(element, accessor, group) {
5088
- super(element);
5157
+ constructor(element, accessor, group, disabled) {
5158
+ super(element, disabled);
5089
5159
  this.accessor = accessor;
5090
5160
  this.group = group;
5091
5161
  this.panelTransfer = LocalSelectionTransfer.getInstance();
@@ -5154,7 +5224,7 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
5154
5224
  this.addDisposables(this._onDrop, this._onDragStart, addDisposableListener(this._element, 'pointerdown', () => {
5155
5225
  this.accessor.doSetGroupActive(this.group);
5156
5226
  }));
5157
- const handler = new GroupDragHandler(this._element, accessor, group);
5227
+ this.handler = new GroupDragHandler(this._element, accessor, group, !!this.accessor.options.disableDnd);
5158
5228
  this.dropTarget = new Droptarget(this._element, {
5159
5229
  acceptedTargetZones: ['center'],
5160
5230
  canDisplayOverlay: (event, position) => {
@@ -5167,7 +5237,7 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
5167
5237
  getOverrideTarget: () => { var _a; return (_a = group.model.dropTargetContainer) === null || _a === void 0 ? void 0 : _a.model; },
5168
5238
  });
5169
5239
  this.onWillShowOverlay = this.dropTarget.onWillShowOverlay;
5170
- this.addDisposables(handler, handler.onDragStart((event) => {
5240
+ this.addDisposables(this.handler, this.handler.onDragStart((event) => {
5171
5241
  this._onDragStart.fire(event);
5172
5242
  }), this.dropTarget.onDrop((event) => {
5173
5243
  this._onDrop.fire(event);
@@ -5176,6 +5246,7 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
5176
5246
  updateDragAndDropState() {
5177
5247
  this._element.draggable = !this.accessor.options.disableDnd;
5178
5248
  toggleClass(this._element, 'dv-draggable', !this.accessor.options.disableDnd);
5249
+ this.handler.setDisabled(!!this.accessor.options.disableDnd);
5179
5250
  }
5180
5251
  }
5181
5252
 
@@ -7669,7 +7740,36 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
7669
7740
 
7670
7741
  const DEFAULT_FLOATING_GROUP_OVERFLOW_SIZE = 100;
7671
7742
  const DEFAULT_FLOATING_GROUP_POSITION = { left: 100, top: 100, width: 300, height: 300 };
7743
+ const DESERIALIZATION_POPOUT_DELAY_MS = 100;
7672
7744
 
7745
+ class PositionCache {
7746
+ constructor() {
7747
+ this.cache = new Map();
7748
+ this.currentFrameId = 0;
7749
+ this.rafId = null;
7750
+ }
7751
+ getPosition(element) {
7752
+ const cached = this.cache.get(element);
7753
+ if (cached && cached.frameId === this.currentFrameId) {
7754
+ return cached.rect;
7755
+ }
7756
+ this.scheduleFrameUpdate();
7757
+ const rect = getDomNodePagePosition(element);
7758
+ this.cache.set(element, { rect, frameId: this.currentFrameId });
7759
+ return rect;
7760
+ }
7761
+ invalidate() {
7762
+ this.currentFrameId++;
7763
+ }
7764
+ scheduleFrameUpdate() {
7765
+ if (this.rafId)
7766
+ return;
7767
+ this.rafId = requestAnimationFrame(() => {
7768
+ this.currentFrameId++;
7769
+ this.rafId = null;
7770
+ });
7771
+ }
7772
+ }
7673
7773
  function createFocusableElement() {
7674
7774
  const element = document.createElement('div');
7675
7775
  element.tabIndex = -1;
@@ -7682,6 +7782,8 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
7682
7782
  this.accessor = accessor;
7683
7783
  this.map = {};
7684
7784
  this._disposed = false;
7785
+ this.positionCache = new PositionCache();
7786
+ this.pendingUpdates = new Set();
7685
7787
  this.addDisposables(exports.DockviewDisposable.from(() => {
7686
7788
  for (const value of Object.values(this.map)) {
7687
7789
  value.disposable.dispose();
@@ -7690,6 +7792,19 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
7690
7792
  this._disposed = true;
7691
7793
  }));
7692
7794
  }
7795
+ updateAllPositions() {
7796
+ if (this._disposed) {
7797
+ return;
7798
+ }
7799
+ // Invalidate position cache to force recalculation
7800
+ this.positionCache.invalidate();
7801
+ // Call resize function directly for all visible panels
7802
+ for (const entry of Object.values(this.map)) {
7803
+ if (entry.panel.api.isVisible && entry.resize) {
7804
+ entry.resize();
7805
+ }
7806
+ }
7807
+ }
7693
7808
  detatch(panel) {
7694
7809
  if (this.map[panel.api.id]) {
7695
7810
  const { disposable, destroy } = this.map[panel.api.id];
@@ -7720,17 +7835,33 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
7720
7835
  this.element.appendChild(focusContainer);
7721
7836
  }
7722
7837
  const resize = () => {
7723
- // TODO propagate position to avoid getDomNodePagePosition calls, possible performance bottleneck?
7724
- const box = getDomNodePagePosition(referenceContainer.element);
7725
- const box2 = getDomNodePagePosition(this.element);
7726
- focusContainer.style.left = `${box.left - box2.left}px`;
7727
- focusContainer.style.top = `${box.top - box2.top}px`;
7728
- focusContainer.style.width = `${box.width}px`;
7729
- focusContainer.style.height = `${box.height}px`;
7730
- toggleClass(focusContainer, 'dv-render-overlay-float', panel.group.api.location.type === 'floating');
7838
+ const panelId = panel.api.id;
7839
+ if (this.pendingUpdates.has(panelId)) {
7840
+ return; // Update already scheduled
7841
+ }
7842
+ this.pendingUpdates.add(panelId);
7843
+ requestAnimationFrame(() => {
7844
+ this.pendingUpdates.delete(panelId);
7845
+ if (this.isDisposed || !this.map[panelId]) {
7846
+ return;
7847
+ }
7848
+ const box = this.positionCache.getPosition(referenceContainer.element);
7849
+ const box2 = this.positionCache.getPosition(this.element);
7850
+ // Use traditional positioning for overlay containers
7851
+ const left = box.left - box2.left;
7852
+ const top = box.top - box2.top;
7853
+ const width = box.width;
7854
+ const height = box.height;
7855
+ focusContainer.style.left = `${left}px`;
7856
+ focusContainer.style.top = `${top}px`;
7857
+ focusContainer.style.width = `${width}px`;
7858
+ focusContainer.style.height = `${height}px`;
7859
+ toggleClass(focusContainer, 'dv-render-overlay-float', panel.group.api.location.type === 'floating');
7860
+ });
7731
7861
  };
7732
7862
  const visibilityChanged = () => {
7733
7863
  if (panel.api.isVisible) {
7864
+ this.positionCache.invalidate();
7734
7865
  resize();
7735
7866
  }
7736
7867
  focusContainer.style.display = panel.api.isVisible ? '' : 'none';
@@ -7825,6 +7956,8 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
7825
7956
  this.map[panel.api.id].disposable.dispose();
7826
7957
  // and reset the disposable to the active reference-container
7827
7958
  this.map[panel.api.id].disposable = disposable;
7959
+ // store the resize function for direct access
7960
+ this.map[panel.api.id].resize = resize;
7828
7961
  return focusContainer;
7829
7962
  }
7830
7963
  }
@@ -8194,6 +8327,13 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
8194
8327
  get floatingGroups() {
8195
8328
  return this._floatingGroups;
8196
8329
  }
8330
+ /**
8331
+ * Promise that resolves when all popout groups from the last fromJSON call are restored.
8332
+ * Useful for tests that need to wait for delayed popout creation.
8333
+ */
8334
+ get popoutRestorationPromise() {
8335
+ return this._popoutRestorationPromise;
8336
+ }
8197
8337
  constructor(container, options) {
8198
8338
  var _a, _b, _c;
8199
8339
  super(container, {
@@ -8242,6 +8382,7 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
8242
8382
  this.onDidMaximizedGroupChange = this._onDidMaximizedGroupChange.event;
8243
8383
  this._floatingGroups = [];
8244
8384
  this._popoutGroups = [];
8385
+ this._popoutRestorationPromise = Promise.resolve();
8245
8386
  this._onDidRemoveGroup = new Emitter();
8246
8387
  this.onDidRemoveGroup = this._onDidRemoveGroup.event;
8247
8388
  this._onDidAddGroup = new Emitter();
@@ -8791,6 +8932,7 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
8791
8932
  this.updateWatermark();
8792
8933
  }
8793
8934
  orthogonalize(position, options) {
8935
+ this.gridview.normalize();
8794
8936
  switch (position) {
8795
8937
  case 'top':
8796
8938
  case 'bottom':
@@ -9034,18 +9176,30 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
9034
9176
  });
9035
9177
  }
9036
9178
  const serializedPopoutGroups = (_b = data.popoutGroups) !== null && _b !== void 0 ? _b : [];
9037
- for (const serializedPopoutGroup of serializedPopoutGroups) {
9179
+ // Create a promise that resolves when all popout groups are created
9180
+ const popoutPromises = [];
9181
+ // Queue popup group creation with delays to avoid browser blocking
9182
+ serializedPopoutGroups.forEach((serializedPopoutGroup, index) => {
9038
9183
  const { data, position, gridReferenceGroup, url } = serializedPopoutGroup;
9039
9184
  const group = createGroupFromSerializedState(data);
9040
- this.addPopoutGroup(group, {
9041
- position: position !== null && position !== void 0 ? position : undefined,
9042
- overridePopoutGroup: gridReferenceGroup ? group : undefined,
9043
- referenceGroup: gridReferenceGroup
9044
- ? this.getPanel(gridReferenceGroup)
9045
- : undefined,
9046
- popoutUrl: url,
9185
+ // Add a small delay for each popup after the first to avoid browser popup blocking
9186
+ const popoutPromise = new Promise((resolve) => {
9187
+ setTimeout(() => {
9188
+ this.addPopoutGroup(group, {
9189
+ position: position !== null && position !== void 0 ? position : undefined,
9190
+ overridePopoutGroup: gridReferenceGroup ? group : undefined,
9191
+ referenceGroup: gridReferenceGroup
9192
+ ? this.getPanel(gridReferenceGroup)
9193
+ : undefined,
9194
+ popoutUrl: url,
9195
+ });
9196
+ resolve();
9197
+ }, index * DESERIALIZATION_POPOUT_DELAY_MS); // 100ms delay between each popup
9047
9198
  });
9048
- }
9199
+ popoutPromises.push(popoutPromise);
9200
+ });
9201
+ // Store the promise for tests to wait on
9202
+ this._popoutRestorationPromise = Promise.all(popoutPromises).then(() => void 0);
9049
9203
  for (const floatingGroup of this._floatingGroups) {
9050
9204
  floatingGroup.overlay.setBounds();
9051
9205
  }
@@ -9092,6 +9246,10 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
9092
9246
  throw err;
9093
9247
  }
9094
9248
  this.updateWatermark();
9249
+ // Force position updates for always visible panels after DOM layout is complete
9250
+ requestAnimationFrame(() => {
9251
+ this.overlayRenderContainer.updateAllPositions();
9252
+ });
9095
9253
  this._onDidLayoutFromJSON.fire();
9096
9254
  }
9097
9255
  clear() {
@@ -9479,11 +9637,13 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
9479
9637
  // remove the group and do not set a new group as active
9480
9638
  this.doRemoveGroup(sourceGroup, { skipActive: true });
9481
9639
  }
9640
+ // Check if destination group is empty - if so, force render the component
9641
+ const isDestinationGroupEmpty = destinationGroup.model.size === 0;
9482
9642
  this.movingLock(() => {
9483
9643
  var _a;
9484
9644
  return destinationGroup.model.openPanel(removedPanel, {
9485
9645
  index: destinationIndex,
9486
- skipSetActive: (_a = options.skipSetActive) !== null && _a !== void 0 ? _a : false,
9646
+ skipSetActive: ((_a = options.skipSetActive) !== null && _a !== void 0 ? _a : false) && !isDestinationGroupEmpty,
9487
9647
  skipSetGroupActive: true,
9488
9648
  });
9489
9649
  });
@@ -9592,7 +9752,6 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
9592
9752
  const target = options.to.position;
9593
9753
  if (target === 'center') {
9594
9754
  const activePanel = from.activePanel;
9595
- const targetActivePanel = to.activePanel;
9596
9755
  const panels = this.movingLock(() => [...from.panels].map((p) => from.model.removePanel(p.id, {
9597
9756
  skipSetActive: true,
9598
9757
  })));
@@ -9602,22 +9761,21 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
9602
9761
  this.movingLock(() => {
9603
9762
  for (const panel of panels) {
9604
9763
  to.model.openPanel(panel, {
9605
- skipSetActive: true, // Always skip setting panels active during move
9764
+ skipSetActive: panel !== activePanel,
9606
9765
  skipSetGroupActive: true,
9607
9766
  });
9608
9767
  }
9609
9768
  });
9610
- if (!options.skipSetActive) {
9611
- // Make the moved panel (from the source group) active
9612
- if (activePanel) {
9613
- this.doSetGroupAndPanelActive(to);
9614
- }
9769
+ // Ensure group becomes active after move
9770
+ if (options.skipSetActive !== true) {
9771
+ // For center moves (merges), we need to ensure the target group is active
9772
+ // unless explicitly told not to (skipSetActive: true)
9773
+ this.doSetGroupAndPanelActive(to);
9615
9774
  }
9616
- else if (targetActivePanel) {
9617
- // Ensure the target group's original active panel remains active
9618
- to.model.openPanel(targetActivePanel, {
9619
- skipSetGroupActive: true
9620
- });
9775
+ else if (!this.activePanel) {
9776
+ // Even with skipSetActive: true, ensure there's an active panel if none exists
9777
+ // This maintains basic functionality while respecting skipSetActive
9778
+ this.doSetGroupAndPanelActive(to);
9621
9779
  }
9622
9780
  }
9623
9781
  else {
@@ -9647,20 +9805,26 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
9647
9805
  if (selectedPopoutGroup.referenceGroup) {
9648
9806
  const referenceGroup = this.getPanel(selectedPopoutGroup.referenceGroup);
9649
9807
  if (referenceGroup && !referenceGroup.api.isVisible) {
9650
- this.doRemoveGroup(referenceGroup, { skipActive: true });
9808
+ this.doRemoveGroup(referenceGroup, {
9809
+ skipActive: true,
9810
+ });
9651
9811
  }
9652
9812
  }
9653
9813
  // Manually dispose the window without triggering restoration
9654
9814
  selectedPopoutGroup.window.dispose();
9655
9815
  // Update group's location and containers for target
9656
9816
  if (to.api.location.type === 'grid') {
9657
- from.model.renderContainer = this.overlayRenderContainer;
9658
- from.model.dropTargetContainer = this.rootDropTargetContainer;
9817
+ from.model.renderContainer =
9818
+ this.overlayRenderContainer;
9819
+ from.model.dropTargetContainer =
9820
+ this.rootDropTargetContainer;
9659
9821
  from.model.location = { type: 'grid' };
9660
9822
  }
9661
9823
  else if (to.api.location.type === 'floating') {
9662
- from.model.renderContainer = this.overlayRenderContainer;
9663
- from.model.dropTargetContainer = this.rootDropTargetContainer;
9824
+ from.model.renderContainer =
9825
+ this.overlayRenderContainer;
9826
+ from.model.dropTargetContainer =
9827
+ this.rootDropTargetContainer;
9664
9828
  from.model.location = { type: 'floating' };
9665
9829
  }
9666
9830
  break;
@@ -9728,8 +9892,12 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
9728
9892
  from.panels.forEach((panel) => {
9729
9893
  this._onDidMovePanel.fire({ panel, from });
9730
9894
  });
9731
- if (!options.skipSetActive) {
9732
- this.doSetGroupAndPanelActive(from);
9895
+ // Ensure group becomes active after move
9896
+ if (options.skipSetActive === false) {
9897
+ // Only activate when explicitly requested (skipSetActive: false)
9898
+ // Use 'to' group for non-center moves since 'from' may have been destroyed
9899
+ const targetGroup = to !== null && to !== void 0 ? to : from;
9900
+ this.doSetGroupAndPanelActive(targetGroup);
9733
9901
  }
9734
9902
  }
9735
9903
  doSetGroupActive(group) {