diff --git a/CHANGELOG.md b/CHANGELOG.md index 170207a..bca7c2b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,12 @@ All notable changes to this project will be documented in this file. Dates are d Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog). +### [7.0.3](https://github.com/eea/volto-tabs-block/compare/7.0.2...7.0.3) - 29 November 2023 + +#### :bug: Bug Fixes + +- fix: delete styles on tab - refs #260427 [dobri1408 - [`6925c95`](https://github.com/eea/volto-tabs-block/commit/6925c958780e9446949c9023053970f042052ecf)] + ### [7.0.2](https://github.com/eea/volto-tabs-block/compare/7.0.1...7.0.2) - 24 November 2023 #### :bug: Bug Fixes diff --git a/cypress/e2e/01-block-tabs.cy.js b/cypress/e2e/01-block-tabs.cy.js index f2c825c..11fa6e7 100644 --- a/cypress/e2e/01-block-tabs.cy.js +++ b/cypress/e2e/01-block-tabs.cy.js @@ -4,6 +4,28 @@ describe('Blocks Tests', () => { beforeEach(slateBeforeEach); afterEach(slateAfterEach); + it('Check tabs widget', () => { + cy.clearSlateTitle(); + cy.getSlateTitle().type('Tabs widget'); + + cy.get('.documentFirstHeading').contains('Tabs widget'); + + cy.getSlate().click(); + + cy.get('.ui.basic.icon.button.block-add-button').first().click(); + cy.get('.blocks-chooser .title').contains('Common').click(); + cy.get('.content.active.common .button.tabs_block') + .contains('Tabs') + .click({ force: true }); + + cy.get('.field-wrapper-title input').last().type('Tab 1'); + cy.get('.tabs-area .accordion.ui').first().click(); + cy.get('#field-assetType-1-data-0').click(); + cy.contains('Icon').click(); + cy.get('#field-icon-2-data-0').type('delete'); + cy.get('#toolbar-save').click(); + }); + it('Add Tabs default template', () => { cy.clearSlateTitle(); cy.getSlateTitle().type('Tabs block default template'); diff --git a/package.json b/package.json index a6c721b..96c50bb 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@eeacms/volto-tabs-block", - "version": "7.0.2", + "version": "7.0.3", "description": "volto-tabs-block: Volto add-on", "main": "src/index.js", "author": "European Environment Agency: IDM2 A-Team", diff --git a/src/components/templates/accordion/Edit.jsx b/src/components/templates/accordion/Edit.jsx index 91ff5f4..c85186c 100644 --- a/src/components/templates/accordion/Edit.jsx +++ b/src/components/templates/accordion/Edit.jsx @@ -51,7 +51,8 @@ const Edit = (props) => { const accordionConfig = config.blocks.blocksConfig[ TABS_BLOCK ].variations.filter((v, _i) => v.id === data.variation); - const { icons, semanticIcon, transformWidth = 800 } = accordionConfig?.[0]; + const { icons, semanticIcon, transformWidth = 800 } = + accordionConfig?.[0] || {}; const tabsContainer = React.useRef(); const [mounted, setMounted] = React.useState(false); diff --git a/src/components/templates/accordion/View.jsx b/src/components/templates/accordion/View.jsx index 9b27e0e..779081a 100644 --- a/src/components/templates/accordion/View.jsx +++ b/src/components/templates/accordion/View.jsx @@ -42,7 +42,8 @@ const View = (props) => { const accordionConfig = config.blocks.blocksConfig[ TABS_BLOCK ].variations.filter((v, _i) => v.id === data.variation); - const { icons, semanticIcon, transformWidth = 800 } = accordionConfig?.[0]; + const { icons, semanticIcon, transformWidth = 800 } = + accordionConfig?.[0] || {}; const tabsContainer = React.useRef(); const [mounted, setMounted] = React.useState(false); diff --git a/src/index.js b/src/index.js index 328a899..5ff14d0 100644 --- a/src/index.js +++ b/src/index.js @@ -107,7 +107,7 @@ const applyConfig = (config) => { }, ], getBlocks: (data) => { - const { blocks = {}, blocks_layout = {} } = data?.data; + const { blocks = {}, blocks_layout = {} } = data?.data || {}; if (blocks_layout?.items?.length) { return { blocks: blocks_layout.items.map((block, index) => ({ diff --git a/src/widgets/TabsWidget.jsx b/src/widgets/TabsWidget.jsx index c54730d..648a7d8 100644 --- a/src/widgets/TabsWidget.jsx +++ b/src/widgets/TabsWidget.jsx @@ -101,7 +101,7 @@ const TabsWidget = (props) => { }, blocks_layout: { ...value.blocks_layout, - items: [...value.blocks_layout?.items, newId], + items: [...(value.blocks_layout?.items || []), newId], }, }); }} @@ -170,7 +170,7 @@ const TabsWidget = (props) => { blocks_layout: { ...value.blocks_layout, items: without( - [...value.blocks_layout?.items], + [...(value.blocks_layout?.items || [])], childId, ), }, @@ -227,6 +227,7 @@ const TabsWidget = (props) => { { setActiveTabId(null); @@ -238,6 +239,17 @@ const TabsWidget = (props) => { ...(activeTabData.size ? { size: activeTabData.size } : {}), }} choices={[]} + onChangeBlock={(block, newData) => { + onChange(id, { + ...value, + blocks: { + ...value.blocks, + [activeTabId]: { + ...newData, + }, + }, + }); + }} onChangeValue={(styleId, styleValue) => onChange(id, { ...value,