Skip to content

Commit

Permalink
fix: error
Browse files Browse the repository at this point in the history
  • Loading branch information
giuliaghisini committed Mar 28, 2024
1 parent 0cf4988 commit de5a535
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 47 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { defineMessages, useIntl } from 'react-intl';

import { Form as UIForm, Grid } from 'semantic-ui-react';
import { isEmpty } from 'lodash';
import {Form, Sidebar} from '@plone/volto/components';
import { Form, Sidebar } from '@plone/volto/components';
import { Portal } from 'react-portal';
import { v4 as uuid } from 'uuid';
import config from '@plone/volto/registry';
Expand All @@ -13,14 +13,9 @@ const messages = defineMessages({
id: 'stickyblocks-blocks',
defaultMessage: 'Blocchi',
},

});

const StickyBlocksConfigurationForm = ({
id,
item,
onChange,
}) => {
const StickyBlocksConfigurationForm = ({ id, item, onChange }) => {
const defaultBlockId = uuid();
const intl = useIntl();

Expand Down Expand Up @@ -59,9 +54,9 @@ const StickyBlocksConfigurationForm = ({
return () => {
document
.querySelector('form.ui.form')
.removeEventListener('click', preventClick);
document.querySelectorAll('form.ui.form input').forEach((item) => {
item.removeEventListener('keypress', preventEnter);
?.removeEventListener('click', preventClick);
document.querySelectorAll('form.ui.form input')?.forEach((item) => {
item?.removeEventListener('keypress', preventEnter);
});
};
}, []);
Expand All @@ -74,34 +69,34 @@ const StickyBlocksConfigurationForm = ({
});
};
return (
<>
<UIForm.Field inline className="wide" id="menu-blocks">
<Grid>
<Grid.Row stretched>
<Grid.Column width={12}>
<div className="wrapper">
<label>{intl.formatMessage(messages.blocks)}</label>
</div>
</Grid.Column>
</Grid.Row>
<Grid.Row stretched>
<Grid.Column width={12}>
<div className="menu-blocks-container">
<Form
key={id}
formData={item}
visual={true}
hideActions
onChangeFormData={onChangeFormBlocks}
/>
</div>
</Grid.Column>
</Grid.Row>
</Grid>
</UIForm.Field>
<Portal node={document.getElementById('sidebar')}>
<Sidebar />
</Portal>
<>
<UIForm.Field inline className="wide" id="menu-blocks">
<Grid>
<Grid.Row stretched>
<Grid.Column width={12}>
<div className="wrapper">
<label>{intl.formatMessage(messages.blocks)}</label>
</div>
</Grid.Column>
</Grid.Row>
<Grid.Row stretched>
<Grid.Column width={12}>
<div className="menu-blocks-container">
<Form
key={id}
formData={item}
visual={true}
hideActions
onChangeFormData={onChangeFormBlocks}
/>
</div>
</Grid.Column>
</Grid.Row>
</Grid>
</UIForm.Field>
<Portal node={document.getElementById('sidebar')}>
<Sidebar />
</Portal>
</>
);
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ const messages = defineMessages({
emptyActivePath: {
id: 'stickyblocks-emptyActivePath',
defaultMessage: 'Select a path',
}
},
});

const defaultItem = (title) => ({
Expand Down Expand Up @@ -92,7 +92,6 @@ const StickyBlocksConfigurationWidget = ({
handleChangeConfiguration(newConfiguration);
};


const onChangeConfiguration = (index, config) => {
let newConfiguration = [...configuration];
newConfiguration[index] = config;
Expand Down Expand Up @@ -184,13 +183,14 @@ const StickyBlocksConfigurationWidget = ({
</Form.Field>
</Grid.Column>
<Grid.Column width={12}>
<Component componentName="StickyBlocksConfigurationForm"
id={`${activeConfigPath}-blocks`}
item={configuration[activeConfigPath]}
onChange={(config) =>
onChangeConfiguration(activeConfigPath, config)
}
/>
<Component
componentName="StickyBlocksConfigurationForm"
id={`${activeConfigPath}-blocks`}
item={configuration[activeConfigPath]}
onChange={(config) =>
onChangeConfiguration(activeConfigPath, config)
}
/>
</Grid.Column>
</Grid>
) : (
Expand Down

0 comments on commit de5a535

Please sign in to comment.