-
-
Notifications
You must be signed in to change notification settings - Fork 117
Description
I'm implementing a sortable drag and drop on the timeline, using dnd-kit
I want to be able to reorded my timeline items in the channel row (not across channels)
This is how I currently implemented it:
<DndContext
sensors={sensors}
collisionDetection={closestCenter}
// onDragEnd={recalculateRoutes}
modifiers={[restrictToHorizontalAxis]}
>
<SortableContext items={epg} strategy={horizontalListSortingStrategy}>
<Epg {...getEpgProps()} isLoading={loading}>
<Layout
{...getLayoutProps()}
renderProgram={
({ program, ...rest }) => (
<TimelineItem
key={program.data.id}
program={program}
{...rest}/>
)
}
/>
</Epg>
</SortableContext>
</DndContext>TimelineItem is a simple component that follows the dnd-kit docs, with the useSortable hook
The problem is that I can only create one SortableContext, that includes the entire epg: so when I try to rearrange one item, it jumps the items from the other channels
Here is an image of my timeline, with no interaction:

Here is an image when I'm moving an item from the second channel. Note how the items from the first channel jumped to the beginning:

Note: all the items have different ids
Basically if I could implement a per-channel wrapper, to which I pass in the TimelineItems as children, I would be able to create one context per channel.
Around the same lines as the other render props on layout, a renderChannelRow:
const renderChannelRow: (({children}: {children: ReactNode}) => ReactNode)What do you think?