Skip to content

Commit 7f11c25

Browse files
committed
fix remaining JS issue after removing lodash
1 parent a6938b7 commit 7f11c25

File tree

3 files changed

+14
-13
lines changed

3 files changed

+14
-13
lines changed

src/blocks/shared-block/edit.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ import './editor.scss';
2121

2222
export default function Edit( { attributes, setAttributes } ) {
2323
const { blockId, blockTitle, display } = attributes;
24-
const hasBlockId = ( blockId && blockId.length ) > 0 ? true : false;
24+
const hasBlockId = blockId && blockId.length > 0 ? true : false;
2525

2626
const [ isEditing, setIsEditing ] = useState( false );
2727

@@ -96,7 +96,7 @@ export default function Edit( { attributes, setAttributes } ) {
9696
</InspectorControls>
9797
{ ! hasBlockId || isEditing ? (
9898
<div className={ 'shared-block-selector-wrapper' }>
99-
{ ! hasBlockId && (
99+
{ hasBlockId && (
100100
<div
101101
className={
102102
'shared-block-selector-wrapper__cancel'

src/blocks/shared-block/sharedBlocksSelector.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
/* global multisiteSharedBlocksEditorData */
2+
/* eslint-disable jsdoc/check-line-alignment */
23

34
/**
45
* External dependencies

src/hooks/sharedBlockIdControls.js

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,9 @@ const sharedBlockIdControls = createHigherOrderComponent( ( BlockEdit ) => {
2323
const { sharedBlockId, sharedBlockIsShared, sharedBlockShareTitle } =
2424
attributes;
2525
const hasShareTitle =
26-
sharedBlockShareTitle && sharedBlockShareTitle > 0 ? true : false;
26+
sharedBlockShareTitle && sharedBlockShareTitle.length > 0
27+
? true
28+
: false;
2729

2830
const getEmptySharedBlockTitle = () => {
2931
return sprintf(
@@ -42,15 +44,11 @@ const sharedBlockIdControls = createHigherOrderComponent( ( BlockEdit ) => {
4244
};
4345

4446
const getTitleCharCount = ( title ) => {
45-
if ( ! hasShareTitle ) {
46-
return '0';
47+
if ( title && title.length > 0 ) {
48+
return count( title, 'characters_including_spaces', {} );
4749
}
4850

49-
return count(
50-
sharedBlockShareTitle,
51-
'characters_including_spaces',
52-
{}
53-
);
51+
return 0;
5452
};
5553

5654
if ( ! blockSupportSharing( name ) ) {
@@ -91,9 +89,11 @@ const sharedBlockIdControls = createHigherOrderComponent( ( BlockEdit ) => {
9189
'Public title for the shared block (%d/200)',
9290
'multisite-shared-blocks'
9391
),
94-
getTitleCharCount(
95-
sharedBlockShareTitle
96-
)
92+
hasShareTitle
93+
? getTitleCharCount(
94+
sharedBlockShareTitle
95+
)
96+
: 0
9797
) }
9898
value={ sharedBlockShareTitle }
9999
onChange={ ( value ) => setTitle( value ) }

0 commit comments

Comments
 (0)