Skip to content

Commit

Permalink
Enable add row/column buttons after having added one.
Browse files Browse the repository at this point in the history
This just allows to be able to add more rows, by enabling the corresponding buttons.

It needs to be revised when programmatically focus to RichText is handled.
  • Loading branch information
ntsekouras committed Jun 29, 2020
1 parent e421896 commit 22daaf8
Showing 1 changed file with 17 additions and 4 deletions.
21 changes: 17 additions & 4 deletions packages/block-library/src/table/edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -291,14 +291,21 @@ export class TableEdit extends Component {

const { attributes, setAttributes } = this.props;
const { sectionName, rowIndex } = selectedCell;
const newRowIndex = rowIndex + delta;

this.setState( { selectedCell: null } );
setAttributes(
insertRow( attributes, {
sectionName,
rowIndex: rowIndex + delta,
rowIndex: newRowIndex,
} )
);
// this just allows to be able to add more rows, by enabling the corresponding
// buttons. It needs to be revised when programmatically focus to RichText is handled
this.createOnFocus( {
sectionName,
rowIndex: newRowIndex,
columnIndex: 0,
} );
}

/**
Expand Down Expand Up @@ -346,13 +353,19 @@ export class TableEdit extends Component {

const { attributes, setAttributes } = this.props;
const { columnIndex } = selectedCell;
const newColumnIndex = columnIndex + delta;

this.setState( { selectedCell: null } );
setAttributes(
insertColumn( attributes, {
columnIndex: columnIndex + delta,
columnIndex: newColumnIndex,
} )
);
// this just allows to be able to add more rows, by enabling the corresponding
// buttons. It needs to be revised when programmatically focus to RichText is handled
this.createOnFocus( {
rowIndex: 0,
columnIndex: newColumnIndex,
} );
}

/**
Expand Down

0 comments on commit 22daaf8

Please sign in to comment.