New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Multiple select, then drag and drop #3601
Comments
did you find any solution? |
Hello!!! Yes I did, I use html 5 and javascript, let me show you. file index.js import Cart from "./Cart"; const styles = { export default function List() { const addItemsToCart = (items, source, dropResult) => { Drag and drop multiple items with React DnDUse Shift or Cmd key to multi-select); } ` file cart.js const styles = { export default function Cart(props) { const [selectedFields, setSelectedFields] = useState([]); const clearItemSelection = () => { const handleItemSelection = (index, cmdKey, shiftKey) => {
}; useEffect(() => { const items = props.fields.map((field, index) => ( {" "} {items}{" "} ); } ` file item.js `import React, { useEffect } from "react"; const getFieldStyle = (isDragging, selected) => { export default function Item(props) { // const opacity = isDragging ? 0.4 : 1; const handleRowSelection = (cmdKey, shiftKey, index) => { useEffect(() => {
}, []); const selected = props.selectedFields.find((field) => props.name === field); ` file ItemsDragLayer.js const layerStyles = { const getFieldStyle = (isDragging) => { const getItemStyles = (currentOffset) => { const { x, y } = currentOffset; const transform = export default function FieldDragLayer(props) { const renderItem = (type, item) => { return ( {renderItem(itemType, item)} ); } ` file ItemsTemplate.js const getFieldStyle = (isDragging) => { const ItemsTemplate = ({ fields }) => { {field} )); return {rows} ;}; export default ItemsTemplate; ` |
For my understanding, to make a multiple selection, you need to make value isDragging of useDrag is correct. const [{ isDragging }, dragRef, previewRef] = useDrag({
item: { id: data.id, originalIndex: index },
isDragging: (monitor) => some logic
type: 'Card',
collect: (monitor) => ({
isDragging: monitor.isDragging(),
}),
}); And then make Card data is correct by setState or dispatch redux actions in useDrop. |
Describe the bug
I have 2 list, and I just want drag and drop objects from one list to another, each item have checkbox for select elemet, so I select multiple items through the checkbox, I get this issue:
Error Objects are not valid as a React child (found: object with keys {name, checked, array}). If you meant to render a collection of children, use an array instead
so, immediately I update the function
useDrag
onItems.js
component, but I'm getting the same issue, I have several weeks with this issue, and I don't know what's wrong? , I'm going to share the code with live reproduction:Reproduction
Live Reproduction
Steps to reproduce the behavior:
Expected behavior
I just want Drag and Drop multiple items simultaneously
Screenshots
image list
Image issue
what's wrong? what I'm doing wrong?
Thanks!!!
The text was updated successfully, but these errors were encountered: