mirror of
https://github.com/strapi/strapi.git
synced 2025-09-25 00:09:18 +00:00
fix: add displayed value to drag layer
This commit is contained in:
parent
9bb4dbf2b0
commit
93c1ba5608
@ -61,11 +61,11 @@ const DragPreview = ({ displayedValue }) => {
|
||||
</ToggleButton>
|
||||
<Box paddingLeft={3}>
|
||||
<Flex>
|
||||
<IconButton>
|
||||
<IconButton noBorder>
|
||||
<Trash />
|
||||
</IconButton>
|
||||
<Box paddingLeft={2}>
|
||||
<IconButton>
|
||||
<IconButton noBorder>
|
||||
<Drag />
|
||||
</IconButton>
|
||||
</Box>
|
||||
|
@ -100,6 +100,9 @@ const DraggedItem = ({
|
||||
useDragAndDrop(!isReadOnly, {
|
||||
type: ItemTypes.COMPONENT,
|
||||
index,
|
||||
item: {
|
||||
displayedValue,
|
||||
},
|
||||
onMoveItem: moveComponentField,
|
||||
onStart() {
|
||||
// Close all collapses
|
||||
|
@ -9,6 +9,7 @@ import { useKeyboardDragAndDrop } from './useKeyboardDragAndDrop';
|
||||
* @type {{
|
||||
* type?: string,
|
||||
* index: number,
|
||||
* item?: object,
|
||||
* onStart?: () => void,
|
||||
* onEnd?: () => void,
|
||||
* } & import('./useKeyboardDragAndDrop').UseKeyboardDragAndDropCallbacks}
|
||||
@ -28,7 +29,17 @@ import { useKeyboardDragAndDrop } from './useKeyboardDragAndDrop';
|
||||
*/
|
||||
export const useDragAndDrop = (
|
||||
active,
|
||||
{ type = 'STRAPI_DND', index, onStart, onEnd, onGrabItem, onDropItem, onCancel, onMoveItem }
|
||||
{
|
||||
type = 'STRAPI_DND',
|
||||
index,
|
||||
item = {},
|
||||
onStart,
|
||||
onEnd,
|
||||
onGrabItem,
|
||||
onDropItem,
|
||||
onCancel,
|
||||
onMoveItem,
|
||||
}
|
||||
) => {
|
||||
const objectRef = useRef(null);
|
||||
|
||||
@ -79,7 +90,7 @@ export const useDragAndDrop = (
|
||||
onStart();
|
||||
}
|
||||
|
||||
return { index };
|
||||
return { index, ...item };
|
||||
},
|
||||
end() {
|
||||
if (onEnd) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user