-
Notifications
You must be signed in to change notification settings - Fork 1
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
What is preview ? #1
Comments
Hi Vincent, Just found that demo app is outdated. Please check demo app again. The preview component will be shown anchored to the cursor when dragging the element. |
Regarding non-customizable horizontal bar. Do you need to change it somehow? Actually, I was not sure what properties of the horizontal bar needed to be customizable, can you describe your case? |
Thanks, I figured out about the preview. I was expecting we could "inject" the preview in the horizontal bar, or change its className (color, margin...). Also, I currently use a dnd list, and for each item, it opens a modal (in a differrent DOM node but the children are declared inside the dnd item), this modal also uses a dnd list. And it doesnt work. If I remove the dnd behavior on the mother list tho, the child list works. So I understand that nested dnd lists (even in different DOM nodes) don't work. Is the context global to the page? |
|
Can you provide a sandbox with a nested example so we can proceed? |
I copy pasted your demo example: https://codesandbox.io/s/red-bird-969e5c?file=/src/App.js |
Well, I understand we cannot use 2 contexts in the same component, I played with the sandbox, trying to have sibling lists, nested lists, etc, everything works with the code from your example. But on my specific case, the "nested" list doesnt work (nested in the React hierarchy but thecomponent is actually created in a different DOM node as a modal). I cannot copy my code since it's quite huge. But I tried to remove the nested lists and make them appear as siblings, I moved the list from a page to a component, etc, I tried everything but still doesnt work. After putting logs in your lib, I figured out I start to lose hope. |
I'm trying to find some time to fix this. I'll update the thread soon. |
It's super weird. In my case, it seems buggy when I add a random callback as property, even not used, like: <Dnd defaultItems={getItems()}> // works
<Dnd defaultItems={getItems()} cb={() => {}}> // doesnt work and / or when I directly use a Dnd list component inside a I tried to reproduce the issue on the sandbox, but I get different errors, as follows: https://codesandbox.io/s/red-bird-969e5c [EDIT] A concrete example, in my case: const Playlists = ({ playlists, onChange }: Props) => {
const [sortedPlaylists, setSortedPlaylists] = useState(playlists);
// After (re)loading
useEffect(() => {
setSortedPlaylists(playlists);
}, [playlists]);
const dndCtx = useDraggableContext({
onDrop: (dragIndex: number, overIndex: number) => {
const nextItems = moveItems(sortedPlaylists, dragIndex, overIndex);
PlaylistService.sort(nextItems)
.then((res) => setSortedPlaylists(res))
.catch(console.log);
},
});
return <>
<Dnd /> // This one always work
<Dnd cb={() => {}} /> // This one works only when I comment the useDraggableContext() call above
</>;
} [EDIT2] if I export |
Hi,
Based on your examples and my attempts, I dont understand what is
preview
and how to use it (I never see a snapshot of the dragged item, only a non-customisable horizontal bar).The text was updated successfully, but these errors were encountered: