From 22daaf886e7f1a00e02be94d553af5daa257a474 Mon Sep 17 00:00:00 2001 From: ntsekouras Date: Fri, 26 Jun 2020 11:23:33 +0300 Subject: [PATCH 1/4] 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, + } ); } /** From 122cbc44adfe2530e29cd99c09509d87ff528796 Mon Sep 17 00:00:00 2001 From: ntsekouras Date: Mon, 6 Jul 2020 17:53:26 +0300 Subject: [PATCH 2/4] set selected cell in state --- packages/block-library/src/table/edit.js | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/packages/block-library/src/table/edit.js b/packages/block-library/src/table/edit.js index a28a4c4f283f82..dee7b90a381421 100644 --- a/packages/block-library/src/table/edit.js +++ b/packages/block-library/src/table/edit.js @@ -301,10 +301,13 @@ export class TableEdit extends Component { ); // 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, + this.setState( { + selectedCell: { + sectionName, + rowIndex: newRowIndex, + columnIndex: 0, + type: 'cell', + }, } ); } @@ -362,9 +365,12 @@ export class TableEdit extends Component { ); // 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, + this.setState( { + selectedCell: { + rowIndex: 0, + columnIndex: newColumnIndex, + type: 'cell', + }, } ); } From 2a399848bb9138425d266a51c880d57cfc858a2a Mon Sep 17 00:00:00 2001 From: Nik Tsekouras Date: Mon, 6 Jul 2020 18:50:59 +0300 Subject: [PATCH 3/4] Change comment description Co-authored-by: Miguel Fonseca --- packages/block-library/src/table/edit.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/packages/block-library/src/table/edit.js b/packages/block-library/src/table/edit.js index dee7b90a381421..1d8e77680b0c8e 100644 --- a/packages/block-library/src/table/edit.js +++ b/packages/block-library/src/table/edit.js @@ -299,8 +299,7 @@ export class TableEdit extends Component { 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 + // Select the first cell of the new row this.setState( { selectedCell: { sectionName, From ce251dcbd9fef78c2587bd6b334e3f23fe6e0421 Mon Sep 17 00:00:00 2001 From: Nik Tsekouras Date: Mon, 6 Jul 2020 18:51:20 +0300 Subject: [PATCH 4/4] Change comment description Co-authored-by: Miguel Fonseca --- packages/block-library/src/table/edit.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/packages/block-library/src/table/edit.js b/packages/block-library/src/table/edit.js index 1d8e77680b0c8e..4bc6ca81bbdb38 100644 --- a/packages/block-library/src/table/edit.js +++ b/packages/block-library/src/table/edit.js @@ -362,8 +362,7 @@ export class TableEdit extends Component { 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 + // Select the first cell of the new column this.setState( { selectedCell: { rowIndex: 0,