Skip to content

Commit

Permalink
KAD-3288 Prevent issue with button block in QL
Browse files Browse the repository at this point in the history
  • Loading branch information
oakesjosh committed Jan 24, 2025
1 parent 5cad8a1 commit fcc0659
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/blocks/advancedbtn/edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -98,14 +98,15 @@ function KadenceButtons(props) {
const { removeBlock } = useDispatch('core/block-editor');
const { replaceInnerBlocks, insertBlock } = useDispatch(blockEditorStore);

const { isUniqueID, isUniqueBlock, previewDevice, childBlocks, parentData, thisBlock } = useSelect(
const { isUniqueID, isUniqueBlock, previewDevice, childBlocks, parentData, thisBlock, isPreviewMode } = useSelect(
(select) => {
return {
isUniqueID: (value) => select('kadenceblocks/data').isUniqueID(value),
isUniqueBlock: (value, clientId) => select('kadenceblocks/data').isUniqueBlock(value, clientId),
previewDevice: select('kadenceblocks/data').getPreviewDeviceType(),
childBlocks: select('core/block-editor').getBlockOrder(clientId),
thisBlock: select('core/block-editor').getBlock(clientId),
isPreviewMode: select('core/block-editor').getSettings().__unstableIsPreviewMode,
parentData: {
rootBlock: select('core/block-editor').getBlock(
select('core/block-editor').getBlockHierarchyRootClientId(clientId)
Expand Down Expand Up @@ -153,7 +154,7 @@ function KadenceButtons(props) {
const migrateUpdate = migrateToInnerblocks(attributes);
setAttributes(migrateUpdate[0]);
replaceInnerBlocks(clientId, migrateUpdate[1]);
} else {
} else if (!isPreviewMode) {
// Delete if no inner blocks.
removeBlock(clientId, true);
}
Expand Down

0 comments on commit fcc0659

Please sign in to comment.