fix: add displayed value to drag layer

This commit is contained in:
Josh 2022-11-25 15:17:45 +00:00
parent 9bb4dbf2b0
commit 93c1ba5608
3 changed files with 18 additions and 4 deletions

View File

@ -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>

View File

@ -100,6 +100,9 @@ const DraggedItem = ({
useDragAndDrop(!isReadOnly, {
type: ItemTypes.COMPONENT,
index,
item: {
displayedValue,
},
onMoveItem: moveComponentField,
onStart() {
// Close all collapses

View File

@ -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) {