Skip to content

OpenProject is the leading open source project management software for product, project and portfolio management. A powerful Jira alternative with agile planning, issue tracking, roadmaps, Gantt charts, time tracking, collaboration features, and more. Available on premises or in the cloud. ⭐ Star us on GitHub

fix dragging to outside of grid

ulfertsd95f51a5cf59
diff --git a/frontend/src/app/modules/grids/grid/drag-and-drop.service.ts b/frontend/src/app/modules/grids/grid/drag-and-drop.service.ts
index a85e5f438ae..becc9ef07b7 100644
--- a/frontend/src/app/modules/grids/grid/drag-and-drop.service.ts
+++ b/frontend/src/app/modules/grids/grid/drag-and-drop.service.ts
@@ -12,7 +12,6 @@ export class GridDragAndDropService implements OnDestroy {
public draggedArea:GridWidgetArea|null;
public placeholderArea:GridWidgetArea|null;
public draggedHeight:number|null;
- private aborted = false;
private mousedOverAreaObserver:Subscription;
constructor(readonly layout:GridAreaService,
@@ -82,41 +81,30 @@ export class GridDragAndDropService implements OnDestroy {
public abort() {
document.dispatchEvent(new Event('mouseup'));
- this.aborted = true;
- this.layout.resetAreas();
- }
-
- public stop() {
- if (!this.draggedArea) {
- return;
- }
-
this.draggedArea = null;
this.placeholderArea = null;
+ this.layout.resetAreas();
}
- public drop(draggedArea:GridWidgetArea, event:CdkDragDrop<GridArea>) {
- if (this.aborted) {
- this.aborted = false;
+ public drop() {
+ if (!this.draggedArea) {
return;
}
- // this.draggedArea is already reset to null at this point
- let dropArea = this.layout.mousedOverArea!;
-
// Set the draggedArea's startRow/startColumn properties
// to the drop zone ones.
// The dragged Area should keep it's height and width normally but will
// shrink if the area would otherwise end outside the grid.
- this.copyPositionButRestrict(dropArea, draggedArea);
+ this.copyPositionButRestrict(this.placeholderArea!, this.draggedArea!);
- if (draggedArea.unchangedSize) {
- return;
+ if (!this.draggedArea!.unchangedSize) {
+ this.layout.writeAreaChangesToWidgets();
+ this.layout.cleanupUnusedAreas();
+ this.layout.rebuildAndPersist();
}
- this.layout.writeAreaChangesToWidgets();
- this.layout.cleanupUnusedAreas();
- this.layout.rebuildAndPersist();
+ this.draggedArea = null;
+ this.placeholderArea = null;
}
private copyPositionButRestrict(source:GridArea, sink:GridWidgetArea) {
diff --git a/frontend/src/app/modules/grids/grid/grid.component.html b/frontend/src/app/modules/grids/grid/grid.component.html
index 6338d449e79..f22a917b633 100644
--- a/frontend/src/app/modules/grids/grid/grid.component.html
+++ b/frontend/src/app/modules/grids/grid/grid.component.html
@@ -19,8 +19,7 @@
<div class="grid--area-content widget-box"
cdkDrag
(cdkDragStarted)="drag.start(area)"
- (cdkDragDropped)="drag.drop(area, $event)"
- (cdkDragEnded)="drag.stop()">
+ (cdkDragDropped)="drag.drop(area)">
<span *ngIf="drag.isDraggable"
class="grid--area-drag-handle