Skip to content

Commit eaeebf9

Browse files
committed
Lodash: Remove _.isEmpty() from site editor
1 parent 074443a commit eaeebf9

File tree

3 files changed

+14
-18
lines changed

3 files changed

+14
-18
lines changed

packages/edit-site/src/components/global-styles/screen-revisions/use-global-styles-revisions.js

+7-5
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,7 @@ import { useSelect } from '@wordpress/data';
55
import { store as coreStore } from '@wordpress/core-data';
66
import { useContext, useMemo } from '@wordpress/element';
77
import { privateApis as blockEditorPrivateApis } from '@wordpress/block-editor';
8-
/**
9-
* External dependencies
10-
*/
11-
import { isEmpty } from 'lodash';
8+
129
/**
1310
* Internal dependencies
1411
*/
@@ -75,7 +72,12 @@ export default function useGlobalStylesRevisions() {
7572
}
7673

7774
// Adds an item for unsaved changes.
78-
if ( isDirty && ! isEmpty( userConfig ) && currentUser ) {
75+
if (
76+
isDirty &&
77+
userConfig &&
78+
Object.keys( userConfig ).length > 0 &&
79+
currentUser
80+
) {
7981
const unsavedRevision = {
8082
id: 'unsaved',
8183
styles: userConfig?.styles,

packages/edit-site/src/components/header-edit-mode/tools-more-menu-group/index.js

+1-6
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,3 @@
1-
/**
2-
* External dependencies
3-
*/
4-
import { isEmpty } from 'lodash';
5-
61
/**
72
* WordPress dependencies
83
*/
@@ -14,7 +9,7 @@ const { Fill: ToolsMoreMenuGroup, Slot } = createSlotFill(
149

1510
ToolsMoreMenuGroup.Slot = ( { fillProps } ) => (
1611
<Slot fillProps={ fillProps }>
17-
{ ( fills ) => ! isEmpty( fills ) && fills }
12+
{ ( fills ) => fills && fills.length > 0 }
1813
</Slot>
1914
);
2015

packages/edit-site/src/components/revisions/index.js

+6-7
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,3 @@
1-
/**
2-
* External dependencies
3-
*/
4-
import { isEmpty } from 'lodash';
5-
61
/**
72
* WordPress dependencies
83
*/
@@ -30,6 +25,10 @@ import EditorCanvasContainer from '../editor-canvas-container';
3025
const { ExperimentalBlockEditorProvider, useGlobalStylesOutputWithConfig } =
3126
unlock( blockEditorPrivateApis );
3227

28+
function isObjectEmpty( object ) {
29+
return ! object || Object.keys( object ).length === 0;
30+
}
31+
3332
function Revisions( { onClose, userConfig, blocks } ) {
3433
const { baseConfig } = useSelect(
3534
( select ) => ( {
@@ -42,7 +41,7 @@ function Revisions( { onClose, userConfig, blocks } ) {
4241
);
4342

4443
const mergedConfig = useMemo( () => {
45-
if ( ! isEmpty( userConfig ) && ! isEmpty( baseConfig ) ) {
44+
if ( ! isObjectEmpty( userConfig ) && ! isObjectEmpty( baseConfig ) ) {
4645
return mergeBaseAndUserConfigs( baseConfig, userConfig );
4746
}
4847
return {};
@@ -65,7 +64,7 @@ function Revisions( { onClose, userConfig, blocks } ) {
6564
const [ globalStyles ] = useGlobalStylesOutputWithConfig( mergedConfig );
6665

6766
const editorStyles =
68-
! isEmpty( globalStyles ) && ! isEmpty( userConfig )
67+
! isObjectEmpty( globalStyles ) && ! isObjectEmpty( userConfig )
6968
? globalStyles
7069
: settings.styles;
7170

0 commit comments

Comments
 (0)