Skip to content

Commit

Permalink
Revert part of 19b7cb3
Browse files Browse the repository at this point in the history
  • Loading branch information
ellatrix committed Aug 23, 2018
1 parent b9c92ed commit ca4af7c
Showing 1 changed file with 35 additions and 5 deletions.
40 changes: 35 additions & 5 deletions packages/block-library/src/table/edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -107,8 +107,14 @@ export default class TableEdit extends Component {
* @param {Array} content A RichText content value.
*/
onChange( content ) {
const { selectedCell } = this.state;

if ( ! selectedCell ) {
return;
}

const { attributes, setAttributes } = this.props;
const { section, rowIndex, columnIndex } = this.state.selectedCell;
const { section, rowIndex, columnIndex } = selectedCell;

setAttributes( updateCellContent( attributes, {
section,
Expand All @@ -124,8 +130,14 @@ export default class TableEdit extends Component {
* @param {number} delta Offset for selected row index at which to insert.
*/
onInsertRow( delta ) {
const { selectedCell } = this.state;

if ( ! selectedCell ) {
return;
}

const { attributes, setAttributes } = this.props;
const { section, rowIndex } = this.state.selectedCell;
const { section, rowIndex } = selectedCell;

this.setState( { selectedCell: null } );
setAttributes( insertRow( attributes, {
Expand All @@ -152,8 +164,14 @@ export default class TableEdit extends Component {
* Deletes the currently selected row.
*/
onDeleteRow() {
const { selectedCell } = this.state;

if ( ! selectedCell ) {
return;
}

const { attributes, setAttributes } = this.props;
const { section, rowIndex } = this.state.selectedCell;
const { section, rowIndex } = selectedCell;

this.setState( { selectedCell: null } );
setAttributes( deleteRow( attributes, { section, rowIndex } ) );
Expand All @@ -165,8 +183,14 @@ export default class TableEdit extends Component {
* @param {number} delta Offset for selected column index at which to insert.
*/
onInsertColumn( delta = 0 ) {
const { selectedCell } = this.state;

if ( ! selectedCell ) {
return;
}

const { attributes, setAttributes } = this.props;
const { section, columnIndex } = this.state.selectedCell;
const { section, columnIndex } = selectedCell;

this.setState( { selectedCell: null } );
setAttributes( insertColumn( attributes, {
Expand All @@ -193,8 +217,14 @@ export default class TableEdit extends Component {
* Deletes the currently selected column.
*/
onDeleteColumn() {
const { selectedCell } = this.state;

if ( ! selectedCell ) {
return;
}

const { attributes, setAttributes } = this.props;
const { section, columnIndex } = this.state.selectedCell;
const { section, columnIndex } = selectedCell;

this.setState( { selectedCell: null } );
setAttributes( deleteColumn( attributes, { section, columnIndex } ) );
Expand Down

0 comments on commit ca4af7c

Please sign in to comment.