Skip to content

Commit

Permalink
[RNMobile] Fix issues with gradients on Button Block and resetting th…
Browse files Browse the repository at this point in the history
…emes (#23075)

* Fix issues with gradients on Button Block

* Reset to Defaults when clearing theme

* Add code comments
  • Loading branch information
chipsnyder authored Jun 15, 2020
1 parent 9b8132d commit b950684
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
4 changes: 2 additions & 2 deletions packages/block-library/src/button/edit.native.js
Original file line number Diff line number Diff line change
Expand Up @@ -176,9 +176,9 @@ class ButtonEdit extends Component {

getBackgroundColor() {
const { backgroundColor, attributes, gradientValue } = this.props;
const { gradient, customGradient } = attributes;
const { customGradient } = attributes;

if ( customGradient || gradient ) {
if ( customGradient || gradientValue ) {
return customGradient || gradientValue;
}
const colorAndStyleProps = getColorAndStyleProps( attributes );
Expand Down
10 changes: 10 additions & 0 deletions packages/editor/src/components/provider/index.native.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import {
import { withDispatch, withSelect } from '@wordpress/data';
import { compose } from '@wordpress/compose';
import { applyFilters } from '@wordpress/hooks';
import { SETTINGS_DEFAULTS } from '@wordpress/block-editor';

const postTypeEntities = [
{ name: 'post', baseURL: '/wp/v2/posts' },
Expand Down Expand Up @@ -107,6 +108,15 @@ class NativeEditorProvider extends Component {

this.subscriptionParentUpdateTheme = subscribeUpdateTheme(
( theme ) => {
// Reset the colors and gradients in case one theme was set with custom items and then updated to a theme without custom elements.
if ( theme.colors === undefined ) {
theme.colors = SETTINGS_DEFAULTS.colors;
}

if ( theme.gradients === undefined ) {
theme.gradients = SETTINGS_DEFAULTS.gradients;
}

this.props.updateSettings( theme );
}
);
Expand Down

0 comments on commit b950684

Please sign in to comment.