fix: self dropping group dnd

This commit is contained in:
mathuo 2023-02-13 16:09:49 +07:00
parent 747049b8f3
commit bf350e404b
No known key found for this signature in database
GPG Key ID: C6EEDEFD6CA07281
3 changed files with 21 additions and 10 deletions

View File

@ -247,17 +247,12 @@ export class Groupview extends CompositeDisposable implements IGroupview {
const data = getPanelData();
if (
data &&
data.panelId === null &&
data.viewId === this.accessor.id &&
data.groupId !== this.id
) {
// prevent dropping on self for group dnd
return true;
}
if (data && data.viewId === this.accessor.id) {
if (data.panelId === null && data.groupId === this.id) {
// don't allow group move to drop on self
return false;
}
const groupHasOnePanelAndIsActiveDragElement =
this._panels.length === 1 && data.groupId === this.id;

View File

@ -106,6 +106,14 @@ export class Tab extends CompositeDisposable implements ITab {
const data = getPanelData();
if (data && this.accessor.id === data.viewId) {
if (
data.panelId === null &&
data.groupId === this.group.id
) {
// don't allow group move to drop on self
return false;
}
return this.panelId !== data.panelId;
}

View File

@ -46,6 +46,14 @@ export class VoidContainer extends CompositeDisposable {
const data = getPanelData();
if (data && this.accessor.id === data.viewId) {
if (
data.panelId === null &&
data.groupId === this.group.id
) {
// don't allow group move to drop on self
return false;
}
// don't show the overlay if the tab being dragged is the last panel of this group
return last(this.group.panels)?.id !== data.panelId;
}