Skip to content

Commit

Permalink
Fix sidebar form update #5779 (#5782)
Browse files Browse the repository at this point in the history
Co-authored-by: Rob Gietema <[email protected]>
  • Loading branch information
sneridagh and robgietema authored Feb 22, 2024
1 parent 21cf5f8 commit 97490da
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 12 deletions.
1 change: 1 addition & 0 deletions news/5779.bugfix
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fix sidebar form update. @robgietema
1 change: 1 addition & 0 deletions packages/volto-slate/news/5779.bugfix
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fix sidebar form update. @robgietema
16 changes: 5 additions & 11 deletions packages/volto-slate/src/blocks/Table/TableBlockEdit.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

import React, { Component } from 'react';
import PropTypes from 'prop-types';
import { map, remove } from 'lodash';
import { isEmpty, map, remove } from 'lodash';
import { Button, Table } from 'semantic-ui-react';
import cx from 'classnames';
import { defineMessages, injectIntl } from 'react-intl';
Expand Down Expand Up @@ -227,7 +227,7 @@ class Edit extends Component {
* @returns {undefined}
*/
componentDidMount() {
if (!this.props.data.table) {
if (!this.props.data.table || isEmpty(this.props.data.table)) {
this.props.onChangeBlock(this.props.block, {
...this.props.data,
table: initialTable,
Expand All @@ -243,7 +243,7 @@ class Edit extends Component {
* @returns {undefined}
*/
UNSAFE_componentWillReceiveProps(nextProps) {
if (!nextProps.data.table) {
if (!nextProps.data.table || isEmpty(nextProps.data.table)) {
this.props.onChangeBlock(nextProps.block, {
...nextProps.data,
table: initialTable,
Expand Down Expand Up @@ -528,10 +528,7 @@ class Edit extends Component {
icon
basic
onClick={this.onDeleteRow}
disabled={
this.props.data.table &&
this.props.data.table.rows.length === 1
}
disabled={this.props.data.table?.rows?.length === 1}
title={this.props.intl.formatMessage(messages.deleteRow)}
aria-label={this.props.intl.formatMessage(messages.deleteRow)}
>
Expand Down Expand Up @@ -569,10 +566,7 @@ class Edit extends Component {
icon
basic
onClick={this.onDeleteCol}
disabled={
this.props.data.table &&
this.props.data.table.rows[0].cells.length === 1
}
disabled={this.props.data.table?.rows?.[0].cells.length === 1}
title={this.props.intl.formatMessage(messages.deleteCol)}
aria-label={this.props.intl.formatMessage(messages.deleteCol)}
>
Expand Down
2 changes: 1 addition & 1 deletion src/components/manage/Form/Form.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -280,7 +280,7 @@ class Form extends Component {
}
if (
this.props.global &&
!isEqual(this.props.globalData, this.state.formData)
!isEqual(this.props.globalData, prevProps.globalData)
) {
this.setState({
formData: this.props.globalData,
Expand Down

0 comments on commit 97490da

Please sign in to comment.