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
Ruby agile-developmentangularbcfboardsbug-trackerganttgantt-chartifcissue-trackerjira-alternativekanbanopenprojectproduct-managementproject-managementproject-planningroadmaprubyscrumtimelineworkflows
Taking into account the dragging direction when reverting a drop
Aleix Suauc4facc0da54a
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.tsindex 61942afd291..4da6f61ecb3 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@@ -8,20 +8,16 @@ export namespace DragAndDropHelpers {return children.indexOf(el);}- export function reinsert(el:HTMLElement, index:number|string, container:HTMLElement) {- index = typeof index === 'string' ? parseInt(index, 10) : index;+ export function reinsert(el:HTMLElement, previousIndex:number|string, container:HTMLElement) {+ previousIndex = typeof previousIndex === 'string' ? parseInt(previousIndex, 10) : previousIndex;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];- // Append to end if unknown index or no child nodes- if (index < 0 || index >= children.length || children.length === 0) {- container.appendChild(el);- }-- // Get the element to insert before- const sibling = children[index];- if (sibling) {- container.insertBefore(el, sibling);+ if (pointOfInsertion) {+ container.insertBefore(el, pointOfInsertion);} else {container.appendChild(el);}