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

prevent invalid resizes on grid

ulferts2f937d6bf29f
diff --git a/frontend/src/app/modules/grids/grid/resize.service.ts b/frontend/src/app/modules/grids/grid/resize.service.ts
index 1bae549baca..20844de3edd 100644
--- a/frontend/src/app/modules/grids/grid/resize.service.ts
+++ b/frontend/src/app/modules/grids/grid/resize.service.ts
@@ -39,8 +39,24 @@ export class GridResizeService {
this.resizedArea = resizedArea;
let resizeTargets = this.layout.gridAreas.filter((area) => {
- return area.startRow >= this.placeholderArea!.startRow &&
- area.startColumn >= this.placeholderArea!.startColumn;
+ // All areas on the same row which are after the current column are valid targets.
+ let sameRow = area.startRow === this.placeholderArea!.startRow &&
+ area.endRow === this.placeholderArea!.endRow &&
+ area.startColumn >= this.placeholderArea!.startColumn;
+
+ // Areas that are on higher (number, they are printed below) rows
+ // are allowed as long as there is guaranteed to always be one widget
+ // before or after the resized to area.
+ let higherRow = area.startRow > this.placeholderArea!.startRow &&
+ area.startColumn >= this.placeholderArea!.startColumn &&
+ this.layout.widgetAreas.some((fixedArea) => {
+ return fixedArea.startRow === area.startRow &&
+ // before
+ (fixedArea.endColumn <= this.placeholderArea!.startColumn ||
+ // after
+ fixedArea.startColumn >= area.endColumn);
+ });
+ return sameRow || higherRow;
});
this.targetIds = resizeTargets