diff --git a/cypress/e2e/style-selection.cy.ts b/cypress/e2e/style-selection.cy.ts index d507818d..361a4462 100644 --- a/cypress/e2e/style-selection.cy.ts +++ b/cypress/e2e/style-selection.cy.ts @@ -11,7 +11,7 @@ describe('Style selector', () => { }) it('has no style value in localStorage', () => { - expect(localStorage.getItem('basemap_2015_global') || '').to.eq('') + expect(localStorage.getItem('basemap_2015_global')).to.be.null }) describe('Style panel', () => { diff --git a/src/services/state-persistor/state-persistor-bgstyle.service.ts b/src/services/state-persistor/state-persistor-bgstyle.service.ts index 0f67546c..e7fe36ed 100644 --- a/src/services/state-persistor/state-persistor-bgstyle.service.ts +++ b/src/services/state-persistor/state-persistor-bgstyle.service.ts @@ -40,11 +40,15 @@ class StatePersistorStyleService { mapStore.bgLayer && styleStore.bgVectorSources.has(mapStore.bgLayer.id) ) { - storageHelper.setValue( - mapStore.bgLayer.name, - value || [], - storageStyleMapper.styleToLocalStorage - ) + if (value && value.length) { + storageHelper.setValue( + mapStore.bgLayer.name, + value || [], + storageStyleMapper.styleToLocalStorage + ) + } else { + storageHelper.removeItem(mapStore.bgLayer.name) + } storageHelper.setValue( SP_KEY_SERIAL, value || [],