Skip to content

Commit

Permalink
Prevent editor forced shorthand styles applying incorrect styles
Browse files Browse the repository at this point in the history
  • Loading branch information
aaronrobertshaw committed Apr 13, 2022
1 parent 461717d commit 84f4f4b
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 1 deletion.
11 changes: 10 additions & 1 deletion packages/block-library/src/table/edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import {
TextControl,
ToggleControl,
ToolbarDropdownMenu,
__experimentalHasSplitBorders as hasSplitBorders,
} from '@wordpress/components';
import {
alignLeft,
Expand Down Expand Up @@ -477,7 +478,15 @@ function TableEdit( {
className={ classnames(
colorProps.className,
borderProps.className,
{ 'has-fixed-layout': hasFixedLayout }
{
'has-fixed-layout': hasFixedLayout,
// This is required in the editor only to overcome
// the fact the editor rewrites individual border
// widths into a shorthand format.
'has-individual-borders': hasSplitBorders(
attributes?.style?.border
),
}
) }
style={ { ...colorProps.style, ...borderProps.style } }
>
Expand Down
13 changes: 13 additions & 0 deletions packages/block-library/src/table/editor.scss
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,19 @@
figcaption {
@include caption-style-theme();
}

// This is only required in the editor to overcome the fact the editor
// rewrites border width styles into shorthand.
table.has-individual-borders {
> *,
tr,
th,
td {
border-width: $border-width;
border-style: solid;
border-color: currentColor;
}
}
}

.blocks-table__placeholder-form.blocks-table__placeholder-form {
Expand Down

0 comments on commit 84f4f4b

Please sign in to comment.