From 69920ec8afd1d2abf378d5ba67058da174467b56 Mon Sep 17 00:00:00 2001 From: Tammie Lister Date: Mon, 2 Dec 2019 15:44:18 +0000 Subject: [PATCH 1/3] Adds fixed table layout to table block I have added this to both the editor and also to the front styles. It might be a point for discussion along with should this be done, but also would the editor and theme show it? Fixes #16045 --- packages/block-library/src/table/editor.scss | 1 + packages/block-library/src/table/style.scss | 1 + 2 files changed, 2 insertions(+) diff --git a/packages/block-library/src/table/editor.scss b/packages/block-library/src/table/editor.scss index 195144afe1be76..aeac0cdb9496bc 100644 --- a/packages/block-library/src/table/editor.scss +++ b/packages/block-library/src/table/editor.scss @@ -6,6 +6,7 @@ height: auto; table { + table-layout: fixed; // Ensure the table element is not full-width when aligned. width: auto; } diff --git a/packages/block-library/src/table/style.scss b/packages/block-library/src/table/style.scss index ba3c949bb7cb3d..be584489668fad 100644 --- a/packages/block-library/src/table/style.scss +++ b/packages/block-library/src/table/style.scss @@ -8,6 +8,7 @@ table { width: 100%; + table-layout: fixed; } // Fixed layout toggle From 4086e47a6560bfa77d14a0cf2960a8181f3f78af Mon Sep 17 00:00:00 2001 From: Tammie Lister Date: Wed, 4 Dec 2019 13:16:41 +0000 Subject: [PATCH 2/3] Removing the option This builds on previous PR and removes option for fixed width, as it's now default. --- packages/block-library/src/table/block.json | 4 ---- packages/block-library/src/table/deprecated.js | 6 ------ packages/block-library/src/table/edit.js | 18 ------------------ packages/block-library/src/table/save.js | 2 -- packages/block-library/src/table/style.scss | 12 +++--------- packages/components/src/button/style.scss | 9 ++------- .../e2e-tests/fixtures/blocks/core__table.json | 1 - .../fixtures/blocks/core__table__caption.json | 1 - .../blocks/core__table__deprecated-1.json | 1 - .../blocks/core__table__scope-attribute.json | 1 - .../blocks/__snapshots__/table.test.js.snap | 5 ----- .../specs/editor/blocks/table.test.js | 4 ---- 12 files changed, 5 insertions(+), 59 deletions(-) diff --git a/packages/block-library/src/table/block.json b/packages/block-library/src/table/block.json index d5e52c7de813d3..a971a2b99520f8 100644 --- a/packages/block-library/src/table/block.json +++ b/packages/block-library/src/table/block.json @@ -2,10 +2,6 @@ "name": "core/table", "category": "formatting", "attributes": { - "hasFixedLayout": { - "type": "boolean", - "default": false - }, "backgroundColor": { "type": "string" }, diff --git a/packages/block-library/src/table/deprecated.js b/packages/block-library/src/table/deprecated.js index 1dd641db9bc07e..be3a7ef9abac4d 100644 --- a/packages/block-library/src/table/deprecated.js +++ b/packages/block-library/src/table/deprecated.js @@ -15,10 +15,6 @@ const supports = { const deprecated = [ { attributes: { - hasFixedLayout: { - type: 'boolean', - default: false, - }, backgroundColor: { type: 'string', }, @@ -116,7 +112,6 @@ const deprecated = [ supports, save( { attributes } ) { const { - hasFixedLayout, head, body, foot, @@ -131,7 +126,6 @@ const deprecated = [ const backgroundClass = getColorClassName( 'background-color', backgroundColor ); const classes = classnames( backgroundClass, { - 'has-fixed-layout': hasFixedLayout, 'has-background': !! backgroundClass, } ); diff --git a/packages/block-library/src/table/edit.js b/packages/block-library/src/table/edit.js index b2aa14dbfea7d3..ab2cb953ba716d 100644 --- a/packages/block-library/src/table/edit.js +++ b/packages/block-library/src/table/edit.js @@ -91,7 +91,6 @@ export class TableEdit extends Component { super( ...arguments ); this.onCreateTable = this.onCreateTable.bind( this ); - this.onChangeFixedLayout = this.onChangeFixedLayout.bind( this ); this.onChange = this.onChange.bind( this ); this.onChangeInitialColumnCount = this.onChangeInitialColumnCount.bind( this ); this.onChangeInitialRowCount = this.onChangeInitialRowCount.bind( this ); @@ -155,16 +154,6 @@ export class TableEdit extends Component { } ) ); } - /** - * Toggles whether the table has a fixed layout or not. - */ - onChangeFixedLayout() { - const { attributes, setAttributes } = this.props; - const { hasFixedLayout } = attributes; - - setAttributes( { hasFixedLayout: ! hasFixedLayout } ); - } - /** * Changes the content of the currently selected cell. * @@ -487,7 +476,6 @@ export class TableEdit extends Component { } = this.props; const { initialRowCount, initialColumnCount } = this.state; const { - hasFixedLayout, caption, head, body, @@ -528,7 +516,6 @@ export class TableEdit extends Component { } const tableClasses = classnames( backgroundColor.class, { - 'has-fixed-layout': hasFixedLayout, 'has-background': !! backgroundColor.color, } ); @@ -553,11 +540,6 @@ export class TableEdit extends Component { - " `; -exports[`Table allows cells to be selected when the cell area outside of the RichText is clicked 1`] = ` -" -




Second cell.
-" -`; exports[`Table allows columns to be aligned 1`] = ` " diff --git a/packages/e2e-tests/specs/editor/blocks/table.test.js b/packages/e2e-tests/specs/editor/blocks/table.test.js index 99c4a195e458bb..63a4a579142d15 100644 --- a/packages/e2e-tests/specs/editor/blocks/table.test.js +++ b/packages/e2e-tests/specs/editor/blocks/table.test.js @@ -207,10 +207,6 @@ describe( 'Table', () => { // Create the table. await clickButton( createButtonLabel ); - // Enable fixed width as it exascerbates the amount of empty space around the RichText. - const [ fixedWidthSwitch ] = await page.$x( "//label[text()='Fixed width table cells']" ); - await fixedWidthSwitch.click(); - // Add multiple new lines to the first cell to make it taller. await page.click( 'td' ); await page.keyboard.type( '\n\n\n\n' ); From 60b5f27fae2f1e72234c32e5e397f837c0351c02 Mon Sep 17 00:00:00 2001 From: Tammie Lister Date: Fri, 20 Dec 2019 21:06:49 +0000 Subject: [PATCH 3/3] Changes from review --- packages/block-library/src/table/deprecated.js | 4 ++++ packages/block-library/src/table/editor.scss | 1 - 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/packages/block-library/src/table/deprecated.js b/packages/block-library/src/table/deprecated.js index be3a7ef9abac4d..0ff1a4c75b54fe 100644 --- a/packages/block-library/src/table/deprecated.js +++ b/packages/block-library/src/table/deprecated.js @@ -15,6 +15,10 @@ const supports = { const deprecated = [ { attributes: { + hasFixedLayout: { + type: 'boolean', + default: false, + }, backgroundColor: { type: 'string', }, diff --git a/packages/block-library/src/table/editor.scss b/packages/block-library/src/table/editor.scss index aeac0cdb9496bc..195144afe1be76 100644 --- a/packages/block-library/src/table/editor.scss +++ b/packages/block-library/src/table/editor.scss @@ -6,7 +6,6 @@ height: auto; table { - table-layout: fixed; // Ensure the table element is not full-width when aligned. width: auto; }