Skip to content

Commit

Permalink
Avoid error when 'styles' settings are removed (#39091)
Browse files Browse the repository at this point in the history
* Edit Post: Avoid error when 'styles' are removed
* Fix useGlobalStylesRenderer
  • Loading branch information
Mamaduka committed Mar 29, 2022
1 parent 274027c commit d032bf3
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
4 changes: 2 additions & 2 deletions packages/edit-post/src/editor.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/**
* External dependencies
*/
import { size, map, without } from 'lodash';
import { forEach, size, map, without } from 'lodash';

/**
* WordPress dependencies
Expand Down Expand Up @@ -163,7 +163,7 @@ function Editor( {
const styles = useMemo( () => {
const themeStyles = [];
const presetStyles = [];
settings.styles.forEach( ( style ) => {
forEach( settings.styles, ( style ) => {
if ( ! style.__unstableType || style.__unstableType === 'theme' ) {
themeStyles.push( style );
} else {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
/**
* External dependencies
*/
import { filter } from 'lodash';

/**
* WordPress dependencies
*/
Expand Down Expand Up @@ -25,7 +30,8 @@ function useGlobalStylesRenderer() {
}

const currentStoreSettings = getSettings();
const nonGlobalStyles = currentStoreSettings?.styles?.filter(
const nonGlobalStyles = filter(
currentStoreSettings.styles,
( style ) => ! style.isGlobalStyles
);
updateSettings( {
Expand Down

0 comments on commit d032bf3

Please sign in to comment.