clauderic / clauderic/dnd-kit

Draggable/Sortable's plugins/sensors/modifiers options should be able to extend manager's configuration, rather than always overriding

Open
#2,019 0 comments 0 reactions 0 assignees View on GitHub
abstract enhancement react triage:done
Dominant language
TypeScript
Stars
17.6k
Forks
924
Avg merge
2d 10h
Merged PRs (30d)
2

Description

## Current Behavior

`Draggable` and `Sortable`'s sensors/modifiers options are typed as a plain array. Passing these options replaces the parent configurations entirely, rather than extending them.

#1966 adds `Customizable` support to `Sortable`'s `plugins` option, allowing users to extend **default** configurations. But if there are also customizations at the manager level, they will be overriden.

## Expected Behavior

Based on existing `Customizable` type, implement a hierarchical inheritance ability.

Hierarchy:

```
Defaults → Manager Customizations → Draggable/Sortable Customizations
```

**Example**

```ts
const manager = new DragDropManager({
plugins: (defaults) => [...defaults, ManagerPlugin],
});

const draggable = new Draggable({
id: 'draggable-1',
element,
}, manager);
// Results
// plugins: [...defaults, ManagerPlugin]

const customizedDraggable = new Draggable({
id: 'draggable-2,
element,
plugins: (defaults) => [...defaults, DraggablePlugin],
}, manager);
// Results
// plugins: [...defaults, ManagerPlugin, DraggablePlugin]
```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.