🐛 Fix wrong position of wrapper when migrating from old schema

This commit is contained in:
Manuel Ruwe
2023-01-11 21:28:24 +01:00
parent e41f63345c
commit ff0f96b4b6
2 changed files with 15 additions and 2 deletions

View File

@@ -14,7 +14,11 @@ export const DashboardWrapper = ({ wrapper }: DashboardWrapperProps) => {
return ( return (
<div <div
className={apps.length > 0 || isEditMode ? defaultClasses : `${defaultClasses} gridstack-empty-wrapper`} className={
apps.length > 0 || widgets.length > 0 || isEditMode
? defaultClasses
: `${defaultClasses} gridstack-empty-wrapper`
}
style={{ transitionDuration: '0s' }} style={{ transitionDuration: '0s' }}
data-wrapper={wrapper.id} data-wrapper={wrapper.id}
ref={refs.wrapper} ref={refs.wrapper}

View File

@@ -131,10 +131,19 @@ const getConfigAndCreateIfNotExsists = (
const category: CategoryType = { const category: CategoryType = {
id: uuidv4(), id: uuidv4(),
name: categoryName, name: categoryName,
position: config.categories.length, position: config.categories.length + 1, // sync up with index of categories
}; };
config.categories.push(category); config.categories.push(category);
// sync up with categories
if (config.wrappers.length < config.categories.length) {
config.wrappers.push({
id: uuidv4(),
position: config.wrappers.length + 1, // sync up with index of categories
});
}
return category; return category;
}; };