From 71be636000ef627967f9c77c5f71b0aba108b3ee Mon Sep 17 00:00:00 2001 From: ntsekouras Date: Fri, 26 Jun 2020 11:23:33 +0300 Subject: [PATCH] Enable add row/column buttons after having added one. 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. --- packages/block-library/src/table/edit.js | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/packages/block-library/src/table/edit.js b/packages/block-library/src/table/edit.js index 49f3149b6cde08..a28a4c4f283f82 100644 --- a/packages/block-library/src/table/edit.js +++ b/packages/block-library/src/table/edit.js @@ -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, + } ); } /** @@ -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, + } ); } /**