Skip to content

Better program separation for different channels #37

@stichiboi

Description

@stichiboi

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:
image

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:
image

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?

Metadata

Metadata

Assignees

No one assigned

    Labels

    help wantedExtra attention is needed

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions