From ff0f96b4b69d1d1d45f974aa65c181076f32f61e Mon Sep 17 00:00:00 2001 From: Manuel Ruwe Date: Wed, 11 Jan 2023 21:28:24 +0100 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B=20=20Fix=20wrong=20position=20of?= =?UTF-8?q?=20wrapper=20when=20migrating=20from=20old=20schema?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/Dashboard/Wrappers/Wrapper/Wrapper.tsx | 6 +++++- src/tools/config/migrateConfig.ts | 11 ++++++++++- 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/src/components/Dashboard/Wrappers/Wrapper/Wrapper.tsx b/src/components/Dashboard/Wrappers/Wrapper/Wrapper.tsx index 21491e9c1..bdc61c10a 100644 --- a/src/components/Dashboard/Wrappers/Wrapper/Wrapper.tsx +++ b/src/components/Dashboard/Wrappers/Wrapper/Wrapper.tsx @@ -14,7 +14,11 @@ export const DashboardWrapper = ({ wrapper }: DashboardWrapperProps) => { return (
0 || isEditMode ? defaultClasses : `${defaultClasses} gridstack-empty-wrapper`} + className={ + apps.length > 0 || widgets.length > 0 || isEditMode + ? defaultClasses + : `${defaultClasses} gridstack-empty-wrapper` + } style={{ transitionDuration: '0s' }} data-wrapper={wrapper.id} ref={refs.wrapper} diff --git a/src/tools/config/migrateConfig.ts b/src/tools/config/migrateConfig.ts index e147496c5..00965af06 100644 --- a/src/tools/config/migrateConfig.ts +++ b/src/tools/config/migrateConfig.ts @@ -131,10 +131,19 @@ const getConfigAndCreateIfNotExsists = ( const category: CategoryType = { id: uuidv4(), name: categoryName, - position: config.categories.length, + position: config.categories.length + 1, // sync up with index of categories }; 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; };