mirror of
https://github.com/makeplane/plane
synced 2024-06-14 14:31:34 +00:00
refactor: manual ordering bugs (#312)
This commit is contained in:
parent
8c15a1519f
commit
8d6a357a7f
@ -86,7 +86,7 @@ export const SingleBoard: React.FC<Props> = ({
|
|||||||
<StrictModeDroppable key={groupTitle} droppableId={groupTitle}>
|
<StrictModeDroppable key={groupTitle} droppableId={groupTitle}>
|
||||||
{(provided, snapshot) => (
|
{(provided, snapshot) => (
|
||||||
<div
|
<div
|
||||||
className={`relative mt-3 h-full space-y-3 px-3 pb-3 ${
|
className={`relative mt-3 h-full px-3 pb-3 ${
|
||||||
snapshot.isDraggingOver ? "bg-indigo-50 bg-opacity-50" : ""
|
snapshot.isDraggingOver ? "bg-indigo-50 bg-opacity-50" : ""
|
||||||
} ${!isCollapsed ? "hidden" : "block"}`}
|
} ${!isCollapsed ? "hidden" : "block"}`}
|
||||||
ref={provided.innerRef}
|
ref={provided.innerRef}
|
||||||
@ -104,7 +104,7 @@ export const SingleBoard: React.FC<Props> = ({
|
|||||||
snapshot.isDraggingOver ? "block" : "hidden"
|
snapshot.isDraggingOver ? "block" : "hidden"
|
||||||
} top-1/2 left-1/2 -translate-y-1/2 -translate-x-1/2 text-xs whitespace-nowrap bg-white p-2 rounded pointer-events-none z-[99999999]`}
|
} top-1/2 left-1/2 -translate-y-1/2 -translate-x-1/2 text-xs whitespace-nowrap bg-white p-2 rounded pointer-events-none z-[99999999]`}
|
||||||
>
|
>
|
||||||
This board is order by {orderBy}
|
This board is ordered by {orderBy}
|
||||||
</div>
|
</div>
|
||||||
</>
|
</>
|
||||||
)}
|
)}
|
||||||
|
@ -188,7 +188,7 @@ export const SingleBoardIssue: React.FC<Props> = ({
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<div
|
<div
|
||||||
className={`rounded border bg-white shadow-sm ${
|
className={`rounded border bg-white shadow-sm mb-3 ${
|
||||||
snapshot.isDragging ? "border-theme bg-indigo-50 shadow-lg" : ""
|
snapshot.isDragging ? "border-theme bg-indigo-50 shadow-lg" : ""
|
||||||
}`}
|
}`}
|
||||||
ref={provided.innerRef}
|
ref={provided.innerRef}
|
||||||
|
@ -116,20 +116,41 @@ export const IssuesView: React.FC<Props> = ({
|
|||||||
const destinationGroupArray = groupedByIssues[destination.droppableId];
|
const destinationGroupArray = groupedByIssues[destination.droppableId];
|
||||||
|
|
||||||
if (destinationGroupArray.length !== 0) {
|
if (destinationGroupArray.length !== 0) {
|
||||||
if (destination.index === 0) newSortOrder = destinationGroupArray[0].sort_order - 10000;
|
// check if dropping in the same group
|
||||||
else if (
|
if (source.droppableId === destination.droppableId) {
|
||||||
(source.droppableId !== destination.droppableId &&
|
// check if dropping at beginning
|
||||||
destination.index === destinationGroupArray.length) ||
|
if (destination.index === 0)
|
||||||
(source.droppableId === destination.droppableId &&
|
newSortOrder = destinationGroupArray[0].sort_order - 10000;
|
||||||
destination.index === destinationGroupArray.length - 1)
|
// check if dropping at last
|
||||||
)
|
else if (destination.index === destinationGroupArray.length - 1)
|
||||||
newSortOrder =
|
newSortOrder =
|
||||||
destinationGroupArray[destinationGroupArray.length - 1].sort_order + 10000;
|
destinationGroupArray[destinationGroupArray.length - 1].sort_order + 10000;
|
||||||
else
|
else {
|
||||||
newSortOrder =
|
if (destination.index > source.index)
|
||||||
(destinationGroupArray[destination.index - 1].sort_order +
|
newSortOrder =
|
||||||
destinationGroupArray[destination.index].sort_order) /
|
(destinationGroupArray[source.index + 1].sort_order +
|
||||||
2;
|
destinationGroupArray[source.index + 2].sort_order) /
|
||||||
|
2;
|
||||||
|
else if (destination.index < source.index)
|
||||||
|
newSortOrder =
|
||||||
|
(destinationGroupArray[source.index - 1].sort_order +
|
||||||
|
destinationGroupArray[source.index - 2].sort_order) /
|
||||||
|
2;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
// check if dropping at beginning
|
||||||
|
if (destination.index === 0)
|
||||||
|
newSortOrder = destinationGroupArray[0].sort_order - 10000;
|
||||||
|
// check if dropping at last
|
||||||
|
else if (destination.index === destinationGroupArray.length)
|
||||||
|
newSortOrder =
|
||||||
|
destinationGroupArray[destinationGroupArray.length - 1].sort_order + 10000;
|
||||||
|
else
|
||||||
|
newSortOrder =
|
||||||
|
(destinationGroupArray[destination.index - 1].sort_order +
|
||||||
|
destinationGroupArray[destination.index].sort_order) /
|
||||||
|
2;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
draggedItem.sort_order = newSortOrder;
|
draggedItem.sort_order = newSortOrder;
|
||||||
|
Loading…
Reference in New Issue
Block a user