Merged in feature/IO-3242-Visual-Production-Board-Vertical-Drag-Bug (pull request #2334)
HOTFIX - feature/IO-3242-Visual-Production-Board-Vertical-Drag-Bug - Fix bug
This commit is contained in:
@@ -20,7 +20,7 @@ const Board = ({ id, className, orientation, cardSettings, ...additionalProps })
|
|||||||
default:
|
default:
|
||||||
return cardSizesVertical.small;
|
return cardSizesVertical.small;
|
||||||
}
|
}
|
||||||
}, [cardSettings]);
|
}, [cardSettings?.cardSize]);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
|
|||||||
@@ -101,11 +101,33 @@ const BoardContainer = ({
|
|||||||
async ({ draggableId, type, source, reason, mode, destination, combine }) => {
|
async ({ draggableId, type, source, reason, mode, destination, combine }) => {
|
||||||
setIsDragging(false);
|
setIsDragging(false);
|
||||||
|
|
||||||
// Only update drag time if it's a valid drop with a different destination
|
// Validate drag type and source
|
||||||
if (type === "lane" && source && destination && !isEqual(source, destination)) {
|
if (type !== "lane" || !source) {
|
||||||
setDragTime(source.droppableId);
|
// Invalid drag type or missing source, attempt to revert if possible
|
||||||
setIsProcessing(true);
|
if (source) {
|
||||||
|
dispatch(
|
||||||
|
actions.moveCardAcrossLanes({
|
||||||
|
fromLaneId: source.droppableId,
|
||||||
|
toLaneId: source.droppableId,
|
||||||
|
cardId: draggableId,
|
||||||
|
index: source.index
|
||||||
|
})
|
||||||
|
);
|
||||||
|
}
|
||||||
|
setIsProcessing(false);
|
||||||
|
try {
|
||||||
|
await onDragEnd({ draggableId, type, source, reason, mode, destination, combine });
|
||||||
|
} catch (err) {
|
||||||
|
console.error("Error in onLaneDrag for invalid drag type or source", err);
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
setDragTime(source.droppableId);
|
||||||
|
setIsProcessing(true);
|
||||||
|
|
||||||
|
// Handle valid drop to a different lane or position
|
||||||
|
if (destination && !isEqual(source, destination)) {
|
||||||
dispatch(
|
dispatch(
|
||||||
actions.moveCardAcrossLanes({
|
actions.moveCardAcrossLanes({
|
||||||
fromLaneId: source.droppableId,
|
fromLaneId: source.droppableId,
|
||||||
@@ -114,14 +136,33 @@ const BoardContainer = ({
|
|||||||
index: destination.index
|
index: destination.index
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
|
} else {
|
||||||
|
// Same-lane drop or no destination, revert to original position
|
||||||
|
dispatch(
|
||||||
|
actions.moveCardAcrossLanes({
|
||||||
|
fromLaneId: source.droppableId,
|
||||||
|
toLaneId: source.droppableId,
|
||||||
|
cardId: draggableId,
|
||||||
|
index: source.index
|
||||||
|
})
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
await onDragEnd({ draggableId, type, source, reason, mode, destination, combine });
|
await onDragEnd({ draggableId, type, source, reason, mode, destination, combine });
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
console.error("Error in onLaneDrag", err);
|
console.error("Error in onLaneDrag", err);
|
||||||
} finally {
|
// Ensure revert on error
|
||||||
setIsProcessing(false);
|
dispatch(
|
||||||
}
|
actions.moveCardAcrossLanes({
|
||||||
|
fromLaneId: source.droppableId,
|
||||||
|
toLaneId: source.droppableId,
|
||||||
|
cardId: draggableId,
|
||||||
|
index: source.index
|
||||||
|
})
|
||||||
|
);
|
||||||
|
} finally {
|
||||||
|
setIsProcessing(false);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
[dispatch, onDragEnd, setDragTime]
|
[dispatch, onDragEnd, setDragTime]
|
||||||
|
|||||||
@@ -133,7 +133,9 @@ const Lane = ({
|
|||||||
Item: ItemComponent
|
Item: ItemComponent
|
||||||
},
|
},
|
||||||
itemContent: (index, item) => <ItemWrapper>{renderDraggable(index, item)}</ItemWrapper>,
|
itemContent: (index, item) => <ItemWrapper>{renderDraggable(index, item)}</ItemWrapper>,
|
||||||
overscan: { main: 10, reverse: 10 }
|
overscan: { main: 10, reverse: 10 },
|
||||||
|
// Ensure a minimum height for empty lanes to allow dropping
|
||||||
|
style: renderedCards.length === 0 ? { minHeight: "5px" } : {}
|
||||||
};
|
};
|
||||||
|
|
||||||
const horizontalProps = {
|
const horizontalProps = {
|
||||||
@@ -149,8 +151,6 @@ const Lane = ({
|
|||||||
|
|
||||||
const componentProps = orientation === "vertical" ? verticalProps : horizontalProps;
|
const componentProps = orientation === "vertical" ? verticalProps : horizontalProps;
|
||||||
|
|
||||||
// If the lane is collapsed, we want to render a div instead of the virtualized list, and we want to set the height to the max height of the lane so that
|
|
||||||
// the lane doesn't shrink when collapsed (in horizontal mode)
|
|
||||||
const finalComponentProps = collapsed
|
const finalComponentProps = collapsed
|
||||||
? orientation === "horizontal"
|
? orientation === "horizontal"
|
||||||
? {
|
? {
|
||||||
@@ -161,9 +161,8 @@ const Lane = ({
|
|||||||
: {}
|
: {}
|
||||||
: componentProps;
|
: componentProps;
|
||||||
|
|
||||||
// If the lane is horizontal and collapsed, we want to render a placeholder so that the lane doesn't shrink to 0 height and grows when
|
// Always render placeholder for empty lanes in vertical mode to ensure droppable area
|
||||||
// a card is dragged over it
|
const shouldRenderPlaceholder = orientation === "vertical" ? collapsed || renderedCards.length === 0 : collapsed;
|
||||||
const shouldRenderPlaceholder = orientation !== "horizontal" && (collapsed || renderedCards.length === 0);
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<HeightMemoryWrapper
|
<HeightMemoryWrapper
|
||||||
@@ -178,8 +177,8 @@ const Lane = ({
|
|||||||
override={orientation !== "horizontal" && (collapsed || !renderedCards.length)}
|
override={orientation !== "horizontal" && (collapsed || !renderedCards.length)}
|
||||||
>
|
>
|
||||||
<div
|
<div
|
||||||
ref={laneRef} // Ensure laneRef is set here
|
ref={laneRef}
|
||||||
style={{ height: "100%", width: "100%" }} // Make it scrollable
|
style={{ height: "100%", width: "100%" }}
|
||||||
className={`react-trello-lane ${collapsed ? "lane-collapsed" : ""}`}
|
className={`react-trello-lane ${collapsed ? "lane-collapsed" : ""}`}
|
||||||
>
|
>
|
||||||
<div {...provided.droppableProps} ref={provided.innerRef} style={{ ...provided.droppableProps.style }}>
|
<div {...provided.droppableProps} ref={provided.innerRef} style={{ ...provided.droppableProps.style }}>
|
||||||
|
|||||||
Reference in New Issue
Block a user