Skip to content

Commit 8b27954

Browse files
committed
fix some errors
1 parent 14d5e25 commit 8b27954

File tree

4 files changed

+11
-5
lines changed

4 files changed

+11
-5
lines changed

src/components/block-css/use-block-style-generator.js

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,14 @@ export const useBlockCssGenerator = props => {
2929
// Keep the generated CSS for editor and return it when only the text attribute has changed.
3030
const oldCss = useRef( null )
3131

32-
const generateCssStyles = useMemo( () => isBlockStyleAttributesModified( blockName, attributes.blockStyle, attributes ),
33-
[ clientId, attributes ] )
32+
const generateCssStyles = useMemo( () => {
33+
if ( ! blockName ) {
34+
return true
35+
}
36+
37+
return isBlockStyleAttributesModified( blockName, attributes.blockStyle, attributes )
38+
},
39+
[ clientId, attributes ] )
3440

3541
const editCss = useMemo( () => {
3642
if ( oldText.current !== attributes.text ) {

src/components/block-styles-control/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ const popoverProps = {
3939
export const BlockStylesControl = props => {
4040
const { blockName, clientId } = props
4141
const blockType = getBlockType( blockName )
42-
const blockAttributesFilter = [ ...STACKABLE_FILTERS[ blockName ], 'uniqueId' ]
42+
const blockAttributesFilter = [ ...( STACKABLE_FILTERS[ blockName ] || [] ), 'uniqueId' ]
4343
const defaultBlockAttributes = useMemo( () => getFilteredAttributes( blockType.attributes, blockAttributesFilter ), [] )
4444

4545
const [ openProNoticeModal, setOpenProNoticeModal ] = useState( false )

src/components/inspector-tabs/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ const InspectorTabs = props => {
7373
return (
7474
<>
7575
<InspectorControls>
76-
{ ! isPro && showProNotice && <BlockStylesControl blockName={ name } clientId={ clientId } /> }
76+
{ ( isPro || showProNotice ) && <BlockStylesControl blockName={ name } clientId={ clientId } /> }
7777
<PanelTabs
7878
tabs={ props.tabs }
7979
initialTab={ activeTab }

src/util/block-styles.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import { select } from '@wordpress/data'
66
export const isBlockStyleAttributesModified = ( blockName, styleSlug, _blockAttrs ) => {
77
const blockStyleAttrs = select( 'stackable/global-block-styles' ).getBlockStyles( blockName )?.find( item => item.slug === styleSlug )?.attributes || {}
88
const blockAttrs = getCleanAttributes( _blockAttrs, blockName )
9-
const currentAttrs = ( [ ...STACKABLE_FILTERS[ blockName ], 'uniqueId', 'generatedCss', 'blockStyle', 'modifiedBlockStyle' ] ).reduce( ( output, attribute ) => {
9+
const currentAttrs = ( [ ...( STACKABLE_FILTERS[ blockName ] || [] ), 'uniqueId', 'generatedCss', 'blockStyle', 'modifiedBlockStyle' ] ).reduce( ( output, attribute ) => {
1010
if ( output[ attribute ] ) {
1111
delete output[ attribute ]
1212
}

0 commit comments

Comments
 (0)