Skip to content

Commit

Permalink
Add story about blocksState
Browse files Browse the repository at this point in the history
  • Loading branch information
tiberiuichim committed Sep 22, 2020
1 parent c4fde42 commit 5685412
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
8 changes: 7 additions & 1 deletion src/ColumnsBlock/ColumnsBlockEdit.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,11 @@ class ColumnsBlockEdit extends React.Component {
// }
// volto-slate needs to be neutral, to work in the main Volto form, but
// also these types of subforms, so it should continue to use batched
// onChangeField, as that works fine.
// onChangeField, as that works fine. So volto-columns-block needs that
// blockState trick to overcome this. If there would be a onChangeBlocks or
// onChangeFormData in Volto core, then BlocksForm could match that API
// and this wouldn't be needed (together with the unstable_batchedUpdates
// calls.
this.blocksState = {};
}

Expand All @@ -46,6 +50,8 @@ class ColumnsBlockEdit extends React.Component {
selected,
} = this.props;

// TODO: need to reinitialize with empty data, there's a bug when trying to
// add a new column and the column block has just been created
const { coldata = empty() } = data;
const columnList = getColumns(coldata);

Expand Down
4 changes: 2 additions & 2 deletions src/ColumnsBlock/ColumnsBlockView.jsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import React from 'react';
import { Grid } from 'semantic-ui-react';
// import { renderBlocks } from '@plone/volto/helpers';
import { getColumns, empty } from './utils';
import { RenderBlocks } from '@plone/volto/components';

import { getColumns, empty } from './utils';

const ColumnsBlockView = (props) => {
const { coldata = empty(), block_title } = props.data;
const columnList = getColumns(coldata);
Expand Down

0 comments on commit 5685412

Please sign in to comment.