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

Test failing fixed

Aleix Suau30084b6d6277
diff --git a/frontend/src/app/modules/common/drag-and-drop/drag-and-drop.helpers.ts b/frontend/src/app/modules/common/drag-and-drop/drag-and-drop.helpers.ts
index edbc9ea2f1b..9510a04a1e7 100644
--- a/frontend/src/app/modules/common/drag-and-drop/drag-and-drop.helpers.ts
+++ b/frontend/src/app/modules/common/drag-and-drop/drag-and-drop.helpers.ts
@@ -10,11 +10,16 @@ export namespace DragAndDropHelpers {
export function reinsert(el:HTMLElement, previousIndex:number|string, container:HTMLElement) {
previousIndex = typeof previousIndex === 'string' ? parseInt(previousIndex, 10) : previousIndex;
-
+ const currentIndex = el.parentNode && Array.from(el.parentNode.children).indexOf(el) || null;
const children = Array.from(container.children);
- const currentIndex = Array.from(el.parentNode!.children).indexOf(el);
- const isDraggingDown = currentIndex > previousIndex;
- const pointOfInsertion = isDraggingDown ? children[previousIndex] : children[previousIndex + 1];
+ let pointOfInsertion;
+
+ if (currentIndex != null) {
+ const isDraggingDown = currentIndex > previousIndex;
+ pointOfInsertion = isDraggingDown ? children[previousIndex] : children[previousIndex + 1];
+ } else {
+ pointOfInsertion = children[previousIndex];
+ }
if (pointOfInsertion) {
container.insertBefore(el, pointOfInsertion);