mirror of
https://github.com/strapi/strapi.git
synced 2026-01-08 05:04:10 +00:00
Fix relation update order
Signed-off-by: soupette <cyril@strapi.io>
This commit is contained in:
parent
dc3de8fac7
commit
27668b1fb5
@ -368,8 +368,16 @@ const reducer = (state = initialState, action) =>
|
||||
oppositeAttributeToCreate.private = rest.private;
|
||||
}
|
||||
|
||||
const indexOfInitialAttribute = updatedAttributes.findIndex(
|
||||
({ name }) => name === initialAttribute.name
|
||||
);
|
||||
const indexOfUpdatedAttribute = updatedAttributes.findIndex(
|
||||
({ name: attrName }) => name === attrName
|
||||
);
|
||||
|
||||
const indexToInsert =
|
||||
updatedAttributes.findIndex(({ name }) => name === initialAttribute.name) + 1;
|
||||
(indexOfInitialAttribute === -1 ? indexOfUpdatedAttribute : indexOfInitialAttribute) +
|
||||
1;
|
||||
|
||||
updatedAttributes.splice(indexToInsert, 0, oppositeAttributeToCreate);
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user