Skip to content

Commit

Permalink
Fix Pullquote text color after unsetting main color (#24600)
Browse files Browse the repository at this point in the history
* unset text color conditionally

* logic fix
  • Loading branch information
ntsekouras authored Aug 19, 2020
1 parent 331014a commit 823e5d7
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions packages/block-library/src/pullquote/edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,7 @@ class PullQuoteEdit extends Component {
const isSolidColorStyle = includes( className, SOLID_COLOR_CLASS );
const needTextColor =
! textColor.color || this.wasTextColorAutomaticallyComputed;
const shouldSetTextColor =
isSolidColorStyle && needTextColor && colorValue;
const shouldSetTextColor = isSolidColorStyle && needTextColor;

if ( isSolidColorStyle ) {
// If we use the solid color style, set the color using the normal mechanism.
Expand All @@ -67,8 +66,14 @@ class PullQuoteEdit extends Component {
}

if ( shouldSetTextColor ) {
this.wasTextColorAutomaticallyComputed = true;
setTextColor( colorUtils.getMostReadableColor( colorValue ) );
if ( colorValue ) {
this.wasTextColorAutomaticallyComputed = true;
setTextColor( colorUtils.getMostReadableColor( colorValue ) );
} else if ( this.wasTextColorAutomaticallyComputed ) {
// We have to unset our previously computed text color on unsetting the main color.
this.wasTextColorAutomaticallyComputed = false;
setTextColor();
}
}
}

Expand Down

0 comments on commit 823e5d7

Please sign in to comment.