Skip to content

Commit

Permalink
Fixed panel to empty panel docking
Browse files Browse the repository at this point in the history
  • Loading branch information
ErikSom committed Oct 14, 2023
1 parent 1e975ec commit 4bfdafd
Show file tree
Hide file tree
Showing 6 changed files with 22 additions and 4 deletions.
2 changes: 2 additions & 0 deletions es/DockLayout.js
Original file line number Diff line number Diff line change
Expand Up @@ -200,8 +200,10 @@ export class DockLayout extends DockPortalManager {
// panel target
if (direction === 'middle') {
layout = Algorithm.addTabToPanel(layout, source, target);
console.log("Panel A");
}
else {
console.log("Panel B");
let newPanel = Algorithm.converToPanel(source);
layout = Algorithm.dockPanelToPanel(layout, newPanel, target, direction);
}
Expand Down
6 changes: 5 additions & 1 deletion es/DockPanel.js
Original file line number Diff line number Diff line change
Expand Up @@ -271,14 +271,18 @@ export class DockPanel extends React.PureComponent {
else {
panel = DragManager.DragState.getData('panel', dockId);
}
const direction = 'after-tab';
let direction = 'after-tab';
const thisPanelData = this.props.panelData;
const lastTab = thisPanelData.tabs[thisPanelData.tabs.length - 1];
const target = lastTab ? lastTab : thisPanelData;
if (!lastTab) {
direction = 'middle';
}
if (tab && tab !== lastTab) {
this.context.dockMove(tab, target, direction);
}
else if (panel && panel !== (lastTab === null || lastTab === void 0 ? void 0 : lastTab.parent)) {
console.log("dock move panel", panel, target, direction);
this.context.dockMove(panel, target, direction);
}
};
Expand Down
2 changes: 2 additions & 0 deletions lib/DockLayout.js
Original file line number Diff line number Diff line change
Expand Up @@ -225,8 +225,10 @@ class DockLayout extends DockPortalManager {
// panel target
if (direction === 'middle') {
layout = Algorithm.addTabToPanel(layout, source, target);
console.log("Panel A");
}
else {
console.log("Panel B");
let newPanel = Algorithm.converToPanel(source);
layout = Algorithm.dockPanelToPanel(layout, newPanel, target, direction);
}
Expand Down
6 changes: 5 additions & 1 deletion lib/DockPanel.js
Original file line number Diff line number Diff line change
Expand Up @@ -296,14 +296,18 @@ class DockPanel extends React.PureComponent {
else {
panel = DragManager.DragState.getData('panel', dockId);
}
const direction = 'after-tab';
let direction = 'after-tab';
const thisPanelData = this.props.panelData;
const lastTab = thisPanelData.tabs[thisPanelData.tabs.length - 1];
const target = lastTab ? lastTab : thisPanelData;
if (!lastTab) {
direction = 'middle';
}
if (tab && tab !== lastTab) {
this.context.dockMove(tab, target, direction);
}
else if (panel && panel !== (lastTab === null || lastTab === void 0 ? void 0 : lastTab.parent)) {
console.log("dock move panel", panel, target, direction);
this.context.dockMove(panel, target, direction);
}
};
Expand Down
2 changes: 2 additions & 0 deletions src/DockLayout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,9 @@ export class DockLayout extends DockPortalManager implements DockContext {
// panel target
if (direction === 'middle') {
layout = Algorithm.addTabToPanel(layout, source, target as PanelData);
console.log("Panel A");
} else {
console.log("Panel B");
let newPanel = Algorithm.converToPanel(source);
layout = Algorithm.dockPanelToPanel(layout, newPanel, target as PanelData, direction);
}
Expand Down
8 changes: 6 additions & 2 deletions src/DockPanel.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import * as React from "react";
import {DockContext, DockContextType, PanelData, TabData} from "./DockData";
import {DockContext, DockContextType, DropDirection, PanelData, TabData} from "./DockData";
import {DockTabs} from "./DockTabs";
import {DragDropDiv} from "./dragdrop/DragDropDiv";
import {DragState} from "./dragdrop/DragManager";
Expand Down Expand Up @@ -325,16 +325,20 @@ export class DockPanel extends React.PureComponent<Props, State> {
panel = DragManager.DragState.getData('panel', dockId);
}

const direction = 'after-tab';
let direction:DropDirection = 'after-tab';

const thisPanelData = this.props.panelData;
const lastTab = thisPanelData.tabs[thisPanelData.tabs.length - 1];

const target = lastTab ? lastTab : thisPanelData;

if(!lastTab){
direction = 'middle';
}
if (tab && tab !== lastTab) {
this.context.dockMove(tab, target, direction);
} else if (panel && panel !== lastTab?.parent) {
console.log("dock move panel", panel, target, direction);
this.context.dockMove(panel, target, direction);
}
}
Expand Down

0 comments on commit 4bfdafd

Please sign in to comment.