Skip to content

Commit

Permalink
Fix overwriting existing line height style when none has been set in …
Browse files Browse the repository at this point in the history
…CoBlocks (#1526)

* Don't force style to null when typography setting is undefined

Fixes #1500

* Update contributor username
  • Loading branch information
p-jackson committed Jun 9, 2020
1 parent 5b28202 commit c4c3b3c
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 16 deletions.
2 changes: 1 addition & 1 deletion CONTRIBUTORS.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ This list is manually curated to include valuable contributions by volunteers th
| @mahdiyazdani | @mahdiyazdani |
| @nicolad | @vadimnicolai |
| @obenland | @obenland |
| @p-jackson | |
| @p-jackson | @philipmjackson |
| @passatgt | @passatgt |
| @ramiy | @ramiy |
| @Reinpal | |
Expand Down
23 changes: 8 additions & 15 deletions src/extensions/typography/apply-style.js
Original file line number Diff line number Diff line change
@@ -1,19 +1,12 @@
function applyStyle( attributes, name ) {
const {
fontFamily,
lineHeight,
letterSpacing,
fontWeight,
textTransform,
} = attributes;
/**
* External dependencies
*/
import pickBy from 'lodash/pickby';

const styleAttributes = [ 'fontFamily', 'lineHeight', 'letterSpacing', 'fontWeight', 'textTransform' ];

const style = {
lineHeight: lineHeight || null,
fontFamily: fontFamily || null,
fontWeight: fontWeight || null,
textTransform: textTransform || null,
letterSpacing: letterSpacing || null,
};
function applyStyle( attributes, name ) {
const style = pickBy( attributes, ( value, key ) => !! value && styleAttributes.includes( key ) );

if ( typeof attributes.customFontSize !== 'undefined' ) {
style.fontSize = attributes.customFontSize + 'px';
Expand Down

0 comments on commit c4c3b3c

Please sign in to comment.