mirror of
https://github.com/strapi/strapi.git
synced 2025-12-25 14:14:10 +00:00
fix: use __temp_key__ for when you've just added components and theres no IDs
This commit is contained in:
parent
b041dcb8c4
commit
04a6cd4861
@ -17,10 +17,12 @@ function useSelect(name) {
|
||||
|
||||
const dynamicDisplayedComponents = useMemo(
|
||||
() =>
|
||||
get(modifiedData, [name], []).map((data) => ({
|
||||
componentUid: data.__component,
|
||||
id: data.id,
|
||||
})),
|
||||
get(modifiedData, [name], []).map((data) => {
|
||||
return {
|
||||
componentUid: data.__component,
|
||||
id: data.id ?? data.__temp_key__,
|
||||
};
|
||||
}),
|
||||
[modifiedData, name]
|
||||
);
|
||||
|
||||
|
||||
@ -88,6 +88,7 @@ const reducer = (state, action) =>
|
||||
? {
|
||||
...state.componentsDataStructure[componentLayoutData.uid],
|
||||
__component: componentLayoutData.uid,
|
||||
__temp_key__: getMaxTempKey(currentValue) + 1,
|
||||
}
|
||||
: {
|
||||
...state.componentsDataStructure[componentLayoutData.uid],
|
||||
|
||||
@ -5,7 +5,7 @@ const getMaxTempKey = (arr) => {
|
||||
|
||||
return Math.max.apply(
|
||||
Math,
|
||||
arr.map((o) => o.__temp_key__)
|
||||
arr.map((o) => o.__temp_key__ ?? o.id)
|
||||
);
|
||||
};
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user