Skip to content

Commit

Permalink
fix: Inject styleWrapper classnames into the accordion custom EditBlo…
Browse files Browse the repository at this point in the history
…ckWrapper and Fix anonymous default export
  • Loading branch information
sneridagh committed Sep 27, 2023
1 parent 051f584 commit 6f5975a
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 6 deletions.
6 changes: 3 additions & 3 deletions cypress/e2e/02-dexterity-controlpanel-layout.cy.js
Expand Up @@ -15,11 +15,12 @@ describe('ControlPanel: Dexterity Content-Types Layout', () => {
'have.text',
'book',
);

cy.visit('/controlpanel/dexterity-types/book/layout');
cy.navigate('/controlpanel/dexterity-types/book/layout');
cy.get('#page-controlpanel-layout').contains(
'Can not edit Layout for book',
);
cy.wait(1000);

cy.get('#page-controlpanel-layout button').click();

// Wait a bit for draftjs to load, without this the title block
Expand Down Expand Up @@ -52,7 +53,6 @@ describe('ControlPanel: Dexterity Content-Types Layout', () => {
.type('Chapter 1')
.should('have.value', 'Chapter 1');

cy.get('.accordion:nth-child(2) > .title > .icon').click();
cy.wait(500);

cy.get(
Expand Down
11 changes: 9 additions & 2 deletions src/components/manage/Blocks/Accordion/EditBlockWrapper.jsx
@@ -1,6 +1,9 @@
import React from 'react';
import { Icon } from '@plone/volto/components';
import { blockHasValue } from '@plone/volto/helpers';
import {
blockHasValue,
buildStyleClassNamesFromData,
} from '@plone/volto/helpers';
import config from '@plone/volto/registry';
import { Button } from 'semantic-ui-react';
import includes from 'lodash/includes';
Expand Down Expand Up @@ -61,12 +64,16 @@ class EditBlockWrapper extends React.Component {
? data.required
: includes(config.blocks.requiredBlocks, type);

const styles = buildStyleClassNamesFromData(data.styles);

return (
<div>
<div
ref={draginfo?.innerRef}
{...(selected ? draginfo?.draggableProps : null)}
className={`block-editor-${data['@type']}`}
className={cx(`block-editor-${data['@type']}`, styles, {
[data.align]: data.align,
})}
>
{(!selected || !visible || disabled) && (
<div
Expand Down
4 changes: 3 additions & 1 deletion src/components/manage/Blocks/Accordion/LayoutSchema.js
Expand Up @@ -110,7 +110,7 @@ const messages = defineMessages({
},
});

export default (intl) => ({
const layoutSchema = (intl) => ({
title: intl.formatMessage(messages.AccordionBlockSettings),
fieldsets: [
{
Expand Down Expand Up @@ -208,3 +208,5 @@ export default (intl) => ({
},
required: [],
});

export default layoutSchema;

0 comments on commit 6f5975a

Please sign in to comment.