Skip to content

Commit 8281e8e

Browse files
committed
Limit the label to list view
1 parent 9c42be9 commit 8281e8e

1 file changed

Lines changed: 9 additions & 5 deletions

File tree

  • packages/block-library/src/button

packages/block-library/src/button/index.js

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -36,13 +36,17 @@ export const settings = {
3636
...a,
3737
text: ( a.text || '' ) + text,
3838
} ),
39-
__experimentalLabel( attributes ) {
39+
__experimentalLabel( attributes, { context } ) {
40+
const { text } = attributes;
41+
4042
const customName = attributes?.metadata?.name;
41-
if ( customName ) {
42-
return customName;
43+
const hasContent = text?.trim().length > 0;
44+
45+
// In the list view, use the block's text as the label.
46+
// If the text is empty, fall back to the default label.
47+
if ( context === 'list-view' && ( customName || hasContent ) ) {
48+
return customName || text;
4349
}
44-
const { text } = attributes;
45-
return ! text || text.length === 0 ? __( 'Button' ) : text;
4650
},
4751
};
4852

0 commit comments

Comments
 (0)