Skip to content

Commit

Permalink
Fix : resolved being dragged item's position problem #105
Browse files Browse the repository at this point in the history
- Being dragged Listitem get affected by modal offset
- Now when it is being dragged, it has different offset

Signed-off-by: bentshrimp <bent_shrimp@kookmin.ac.kr>
  • Loading branch information
bentshrimp committed Oct 11, 2023
1 parent c535642 commit 8a26a48
Showing 1 changed file with 29 additions and 12 deletions.
41 changes: 29 additions & 12 deletions src/components/common/template/TemplateList.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import {

// props -> type(pr, readme, contributing)
export function TemplateList(props) {
const viewportNode = document.getElementById("viewport");
// React state to track order of items
const [selectedData, setSelectedData] = useState([]);
const [data, setData] = useState([]);
Expand Down Expand Up @@ -143,18 +144,34 @@ export function TemplateList(props) {
draggableId={item._id}
index={index}
>
{(provided) => (
<ListItem
{...provided.draggableProps}
{...provided.dragHandleProps}
ref={provided.innerRef}
>
{item.title}
<button onClick={() => handleRemove(item._id)}>
Remove
</button>
</ListItem>
)}
{(provided, snapshot) => {
if (snapshot.isDragging) {
provided.draggableProps.style.left =
provided.draggableProps.style.offsetLeft;
provided.draggableProps.style.top =
provided.draggableProps.style.offsetTop;
}
return (
<ListItem
components="div"
disablePadding
{...provided.draggableProps}
{...provided.dragHandleProps}
ref={provided.innerRef}
>
<ListItemText
primary={item.title}
id="PR-desc"
variant="h6"
gutterBottom
color="textSecondary"
/>
<button onClick={() => handleRemove(item._id)}>
Remove
</button>
</ListItem>
);
}}
</Draggable>
))}
</ul>
Expand Down

0 comments on commit 8a26a48

Please sign in to comment.