Skip to content

Commit 6a250cb

Browse files
committed
use set, fix reset
1 parent 16d326f commit 6a250cb

File tree

1 file changed

+5
-4
lines changed
  • src/components/block-styles-control

1 file changed

+5
-4
lines changed

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

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -63,9 +63,9 @@ export const BlockStylesControl = props => {
6363
const globalBlockStyles = select( 'stackable/global-block-styles' ).getBlockStyles( blockName )
6464

6565
const invalidNames = globalBlockStyles.reduce( ( output, item ) => {
66-
output[ item.name.toLowerCase() ] = 1
66+
output.add( item.name.toLowerCase() )
6767
return output
68-
}, {} )
68+
}, new Set() )
6969

7070
const blockStyleOptions = globalBlockStyles.reduce( ( options, blockStyle ) => {
7171
options.push( { label: blockStyle.name, value: blockStyle.slug } )
@@ -157,12 +157,13 @@ export const BlockStylesControl = props => {
157157
value={ isModified }
158158
default={ false }
159159
onChange={ () => {
160-
if ( ! blockStyle ) {
160+
const blockStyleAttrs = globalBlockStyles.find( item => item.slug === blockStyle )?.attributes
161+
162+
if ( ! blockStyle || blockStyleAttrs === undefined ) {
161163
setAttributes( defaultBlockAttributes )
162164
return
163165
}
164166

165-
const blockStyleAttrs = globalBlockStyles.find( item => item.slug === blockStyle ).attributes
166167
setAttributes( {
167168
...defaultBlockAttributes,
168169
...blockStyleAttrs,

0 commit comments

Comments
 (0)