Skip to content

Commit

Permalink
Fix the reorder offset issue
Browse files Browse the repository at this point in the history
Signed-off-by: popcorny <[email protected]>
  • Loading branch information
popcornylu committed Sep 26, 2024
1 parent e111ee5 commit 90bdb34
Showing 1 changed file with 27 additions and 15 deletions.
42 changes: 27 additions & 15 deletions js/src/components/check/CheckList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -105,21 +105,33 @@ export const CheckList = ({
draggableId={check.check_id}
index={index}
>
{(provided) => (
<Flex
ref={provided.innerRef}
{...provided.draggableProps}
{...provided.dragHandleProps}
w="full"
>
<ChecklistItem
key={check.check_id}
check={check}
selected={check.check_id === selectedItem}
onSelect={onCheckSelected}
/>
</Flex>
)}
{(provided, snapshot) => {
// see https://github.com/atlassian/react-beautiful-dnd/issues/1881#issuecomment-691237307
if (snapshot.isDragging) {
const props = provided.draggableProps as any;
const offset = { x: 0, y: 80 };
const x = props.style.left - offset.x;
const y = props.style.top - offset.y;
props.style.left = x;
props.style.top = y;
}

return (
<Flex
ref={provided.innerRef}
{...provided.draggableProps}
{...provided.dragHandleProps}
w="full"
>
<ChecklistItem
key={check.check_id}
check={check}
selected={check.check_id === selectedItem}
onSelect={onCheckSelected}
/>
</Flex>
);
}}
</Draggable>
))}
{provided.placeholder}
Expand Down

0 comments on commit 90bdb34

Please sign in to comment.