You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Note: There is a new recommended drag and drop implementation with full keyboard functionality, which replaces this implementation. To adhere to our new recommendations, refer to the [drag and drop demos](/components/drag-and-drop/react-demos).
86
+
To enable drag and drop, wrap the `<DataList>` component with `<DragDropSort>`, define the `variant` property as "DataList", and pass both the sortable items and `onDrop` callback to `<DragDropSort>`. `<DragDropSort>` will create the component's usual children internally based on the items property, so children should not be passed to the wrapped component.
87
87
88
-
Previously, draggable data lists had their own API for the [drag and drop component](/components/drag-and-drop), which wasn't flexible enough to allow custom styling for items as they are dragged. To address this disparity, `<DragDrop>`, `<Draggable>`, and `<Droppable>` components were added to replace our now deprecated HTML5-based API. Keyboard and screen reader accessibility for the `<DragDrop>`component is still in development.
88
+
Full drag and drop details can be found on the [drag and drop](/components/drag-and-drop)component page.
To enable multiple drop zones, and create the desired amount of `<Droppable>` components within a `<DragDropContainer>`.
97
+
98
+
Each `<Droppable>` should define the `wrapper` property as the component that acts as the drop zone, `<DataList>`, and the `items` property of their respective draggable items as an array of `<DraggableObject>` data. `<DragDropContainer>` should be passed the `onDrop`, `onContainerMove`, and `onCancel` callbacks to handle items being dropped, items moving between droppable containers, and what happens if the drag is cancelled respectively. `<DragDropContainer>` should also be given a `Record` representing all sortable drop zones' items. Both components should define the `variant` property as "DataList".
99
+
100
+
Full drag and drop details can be found on the [drag and drop](/components/drag-and-drop) component page.
Copy file name to clipboardExpand all lines: packages/react-core/src/components/DualListSelector/examples/DualListSelector.md
+16-14Lines changed: 16 additions & 14 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -22,7 +22,7 @@ import AngleRightIcon from '@patternfly/react-icons/dist/esm/icons/angle-right-i
22
22
import PficonSortCommonAscIcon from '@patternfly/react-icons/dist/esm/icons/pficon-sort-common-asc-icon';
23
23
import SearchIcon from '@patternfly/react-icons/dist/esm/icons/search-icon';
24
24
import EllipsisVIcon from '@patternfly/react-icons/dist/esm/icons/ellipsis-v-icon';
25
-
import { DragDrop, Draggable, Droppable } from '@patternfly/react-core/deprecated';
25
+
import { DragDropSort, DragDropContainer, Droppable as NewDroppable } from '@patternfly/react-drag-drop';
26
26
27
27
## Examples
28
28
@@ -78,22 +78,24 @@ The dual list selector is built in a composable manner to make customization eas
78
78
79
79
```
80
80
81
-
### Drag and drop
81
+
### Draggable
82
82
83
-
This example only allows reordering the contents of the "chosen" pane with drag and drop. To make a pane able to be reordered:
83
+
To enable drag and drop, wrap the `<DualListSelectorList>` component with `<DragDropSort>`, define the `variant` property as "DualListSelectorList", and pass both the sortable items and `onDrop` callback to `<DragDropSort>`. `<DragDropSort>` will create the component's usual children internally based on the items property, so children inside the `<DualListSelectorList>` should not be passed to the wrapped component.
84
84
85
-
- wrap the `DualListSelectorPane` in a `DragDrop` component
86
-
- wrap the `DualListSelectorList` in a `Droppable` component
87
-
- wrap the `DualListSelectorListItem` components in a `Draggable` component
88
-
- define an `onDrop` callback which reorders the sortable options.
89
-
- The `onDrop` function provides the starting location and destination location for a dragged item. It should return
90
-
true to enable the 'drop' animation in the new location and false to enable the 'drop' animation back to the item's
91
-
old position.
92
-
- define an `onDrag` callback which ensures that the drag event will not cross hairs with the `onOptionSelect` click
93
-
event set on the option. Note: the `ignoreNextOptionSelect` state value is used to prevent selection while dragging.
85
+
Full drag and drop details can be found on the [drag and drop](/components/drag-and-drop) component page.
94
86
95
-
Note: Keyboard accessibility and screen reader accessibility for the `DragDrop` component are still in development.
To enable multiple drop zones, wrap the `<DualListSelector>` component with `<DragDropContainer>`, and create the desired amount of `<Droppable>` components within `<DragDropContainer>`. `<Droppable>` components should be located where `<DualListSelectorList>` usually would go for each pane to be made draggable.
94
+
95
+
Each `<Droppable>` should define the `wrapper` property as the component that acts as the drop zone, `<DualListSelectorList>`, and the `items` property of their respective draggable items as an array of `<DraggableObject>` data. `<DragDropContainer>` should be passed the `onDrop`, `onContainerMove`, and `onCancel` callbacks to handle items being dropped, items moving between droppable containers, and what happens if the drag is cancelled respectively. `<DragDropContainer>` should also be given a `Record` representing all sortable drop zones' items. Both components should define the `variant` property as "DualListSelectorList".
96
+
97
+
Full drag and drop details can be found on the [drag and drop](/components/drag-and-drop) component page.
0 commit comments