We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 9c42be9 commit 8281e8eCopy full SHA for 8281e8e
1 file changed
packages/block-library/src/button/index.js
@@ -36,13 +36,17 @@ export const settings = {
36
...a,
37
text: ( a.text || '' ) + text,
38
} ),
39
- __experimentalLabel( attributes ) {
+ __experimentalLabel( attributes, { context } ) {
40
+ const { text } = attributes;
41
+
42
const customName = attributes?.metadata?.name;
- if ( customName ) {
- 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;
49
}
- const { text } = attributes;
- return ! text || text.length === 0 ? __( 'Button' ) : text;
50
},
51
};
52
0 commit comments