From f9a54b9f2fee3f78d0aa27df4e8a1477fc90d1fb Mon Sep 17 00:00:00 2001 From: Josh Oakes Date: Fri, 16 Feb 2024 13:03:19 -0600 Subject: [PATCH] KAD-2002 Fix list view title for Kadence Pane --- src/early-filters.js | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/src/early-filters.js b/src/early-filters.js index fd5053a04..de31648d2 100644 --- a/src/early-filters.js +++ b/src/early-filters.js @@ -38,6 +38,11 @@ export function blockMetadataAttribute( settings ) { if ( context === 'list-view' && get( metadata, 'name', '' ) !== '' ) { return metadata.name; } else if ( undefined !== contentLabel && get( attributes, contentLabel ) !== '' ) { + // Accordion pane block is stored as an array, doing this instead of deprecation on parent accordion. + if( get( settings, 'name' ) === 'kadence/pane' && get( attributes, contentLabel ) instanceof Array ) { + return convertArrayTitleToString( get( attributes, contentLabel ) ); + } + return get( attributes, contentLabel ); } }; @@ -47,4 +52,18 @@ export function blockMetadataAttribute( settings ) { return settings; } +function convertArrayTitleToString(arr) { + let result = ''; + + arr.forEach(item => { + if (typeof item === 'string') { + result += item; + } else if (item.props && item.props.children) { + result += convertArrayTitleToString(item.props.children); + } + }); + + return result; +} + addFilter( 'blocks.registerBlockType', 'kadence/block-label', blockMetadataAttribute );