Skip to content

Commit

Permalink
Fixing so empty caption isn't created when inserting global style.
Browse files Browse the repository at this point in the history
  • Loading branch information
ronaldhuereca committed Aug 19, 2024
1 parent 852f185 commit c6b61e1
Show file tree
Hide file tree
Showing 6 changed files with 55,057 additions and 44 deletions.
2 changes: 1 addition & 1 deletion build/index.asset.php
Original file line number Diff line number Diff line change
@@ -1 +1 @@
<?php return array('dependencies' => array('react', 'wp-a11y', 'wp-block-editor', 'wp-blocks', 'wp-components', 'wp-compose', 'wp-data', 'wp-element', 'wp-escape-html', 'wp-hooks', 'wp-i18n', 'wp-keycodes', 'wp-plugins', 'wp-url'), 'version' => '4ca338746fe3ccac4ba9');
<?php return array('dependencies' => array('react', 'wp-a11y', 'wp-block-editor', 'wp-blocks', 'wp-components', 'wp-compose', 'wp-data', 'wp-element', 'wp-escape-html', 'wp-hooks', 'wp-i18n', 'wp-keycodes', 'wp-plugins', 'wp-url'), 'version' => '8399fdb3dcc261cff327');
4,607 changes: 4,569 additions & 38 deletions build/index.css

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions build/index.css.map

Large diffs are not rendered by default.

50,486 changes: 50,483 additions & 3 deletions build/index.js

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions build/index.js.map

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions src/components/GlobalStylesPicker/ButtonPreview/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -101,14 +101,14 @@ const GlobalStylesButtonPreview = ( props ) => {
};

// If there is no caption block, but there are attributes to apply, create one.
if ( ! captionBlock && ( captionAttributes || captionAttributes.length > 0 ) ) {
if ( ! captionBlock && ( Object.keys( captionAttributes ).length > 1 || captionAttributes.length > 1 ) ) {
const newBlocks = createBlock( 'dlxplugins/photo-caption-block', captionAttributes );
insertBlock( newBlocks, undefined, props.clientId );
props.setAttributes( { hasCaption: true } );
}

// If there is a caption block and attributes to apply, apply them.
if ( captionBlock && ( captionAttributes || captionAttributes.length > 0 ) ) {
if ( captionBlock && ( Object.keys( captionAttributes ).length > 1 || captionAttributes.length > 1 ) ) {
const captionBlockAttributes = { ...captionAttributes, ...uniqueIdAttribute };
updateBlockAttributes( captionBlock.clientId, captionBlockAttributes );
}
Expand Down

0 comments on commit c6b61e1

Please sign in to comment.