mirror of
https://github.com/strapi/strapi.git
synced 2025-11-15 01:28:07 +00:00
Merge pull request #16441 from strapi/fix/nested-repeatable-components-can-be-reordered
This commit is contained in:
commit
2edcb60e35
@ -97,11 +97,17 @@ const DraggedItem = ({
|
|||||||
const accordionRef = useRef(null);
|
const accordionRef = useRef(null);
|
||||||
const { formatMessage } = useIntl();
|
const { formatMessage } = useIntl();
|
||||||
|
|
||||||
const [parentFieldName] = componentFieldName.split('.');
|
/**
|
||||||
|
* The last item in the fieldName array will be the index of this component.
|
||||||
|
* Drag and drop should be isolated to the parent component so nested repeatable
|
||||||
|
* components are not affected by the drag and drop of the parent component in
|
||||||
|
* their own re-ordering context.
|
||||||
|
*/
|
||||||
|
const componentKey = componentFieldName.split('.').slice(0, -1).join('.');
|
||||||
|
|
||||||
const [{ handlerId, isDragging, handleKeyDown }, boxRef, dropRef, dragRef, dragPreviewRef] =
|
const [{ handlerId, isDragging, handleKeyDown }, boxRef, dropRef, dragRef, dragPreviewRef] =
|
||||||
useDragAndDrop(!isReadOnly, {
|
useDragAndDrop(!isReadOnly, {
|
||||||
type: `${ItemTypes.COMPONENT}_${parentFieldName}`,
|
type: `${ItemTypes.COMPONENT}_${componentKey}`,
|
||||||
index,
|
index,
|
||||||
item: {
|
item: {
|
||||||
displayedValue,
|
displayedValue,
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user