Skip to content

Commit e2d89a8

Browse files
Mamadukaellatrix
andauthored
Block Editor: Deprecate '__experimentalGetReusableBlockTitle' selector (#60278)
Co-authored-by: Mamaduka <[email protected]> Co-authored-by: ellatrix <[email protected]>
1 parent 5e8a210 commit e2d89a8

File tree

2 files changed

+16
-10
lines changed

2 files changed

+16
-10
lines changed

packages/block-editor/src/components/use-block-display-information/index.js

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import {
66
store as blocksStore,
77
isReusableBlock,
88
isTemplatePart,
9+
__experimentalGetBlockLabel as getBlockLabel,
910
} from '@wordpress/blocks';
1011
import { __ } from '@wordpress/i18n';
1112

@@ -68,24 +69,21 @@ export default function useBlockDisplayInformation( clientId ) {
6869
return useSelect(
6970
( select ) => {
7071
if ( ! clientId ) return null;
71-
const {
72-
getBlockName,
73-
getBlockAttributes,
74-
__experimentalGetReusableBlockTitle,
75-
} = select( blockEditorStore );
72+
const { getBlockName, getBlockAttributes } =
73+
select( blockEditorStore );
7674
const { getBlockType, getActiveBlockVariation } =
7775
select( blocksStore );
7876
const blockName = getBlockName( clientId );
7977
const blockType = getBlockType( blockName );
8078
if ( ! blockType ) return null;
8179
const attributes = getBlockAttributes( clientId );
8280
const match = getActiveBlockVariation( blockName, attributes );
83-
const isReusable = isReusableBlock( blockType );
84-
const resusableTitle = isReusable
85-
? __experimentalGetReusableBlockTitle( attributes.ref )
81+
const isSynced =
82+
isReusableBlock( blockType ) || isTemplatePart( blockType );
83+
const syncedTitle = isSynced
84+
? getBlockLabel( blockType, attributes )
8685
: undefined;
87-
const title = resusableTitle || blockType.title;
88-
const isSynced = isReusable || isTemplatePart( blockType );
86+
const title = syncedTitle || blockType.title;
8987
const positionLabel = getPositionTypeLabel( attributes );
9088
const blockTypeInfo = {
9189
isSynced,

packages/block-editor/src/store/selectors.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2534,6 +2534,14 @@ export const __experimentalGetReusableBlockTitle = createRegistrySelector(
25342534
( select ) =>
25352535
createSelector(
25362536
( state, ref ) => {
2537+
deprecated(
2538+
"wp.data.select( 'core/block-editor' ).__experimentalGetReusableBlockTitle",
2539+
{
2540+
since: '6.6',
2541+
version: '6.8',
2542+
}
2543+
);
2544+
25372545
const reusableBlock = unlock( select( STORE_NAME ) )
25382546
.getReusableBlocks()
25392547
.find( ( block ) => block.id === ref );

0 commit comments

Comments
 (0)