Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Global Styles: say "No blocks found" when a search comes up empty
With the customized filter on, a search matching nothing said the user
had not customized any blocks, which is wrong when they have but the
query does not match. Fall back to the search wording whenever a query
is present.

Border is now reported by the changelist, so the test that used it as an
example of an unreported property uses custom CSS instead.
  • Loading branch information
ramonjd committed Aug 18, 2026
commit b2519a2e65201b7decb36fe768f54f26d1ede03f
22 changes: 16 additions & 6 deletions packages/global-styles-ui/src/screen-block-list.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -109,9 +109,8 @@ interface BlockStyle {
* A changed style variation is named rather than described: whatever was
* changed inside it, it contributes one "{Label} variation" entry.
*
* Returns an empty string when nothing can be named. `getGlobalStylesChangelist`
* only reports background, color, typography and spacing, so a block changed
* only through, say, its border counts as customized but has nothing to show.
* Returns an empty string when nothing can be named: a block changed only
* through its custom CSS counts as customized but has nothing to show.
*
* @param user The user's global styles config.
* @param blockName The block to summarize, e.g. `core/quote`.
Expand Down Expand Up @@ -247,9 +246,17 @@ function BlockMenuItem( { block, summary }: BlockMenuItemProps ) {
);
}

function EmptyBlockList( { styleFilter }: { styleFilter: StyleFilter } ) {
function EmptyBlockList( {
filterValue,
styleFilter,
}: {
filterValue: string;
styleFilter: StyleFilter;
} ) {
// While searching, an empty list means the search matched nothing, whether
// or not the customized filter is also on.
const label =
'customized' === styleFilter
'customized' === styleFilter && ! filterValue
? __( "You haven't customized any blocks yet." )
: __( 'No blocks found.' );
return (
Expand Down Expand Up @@ -343,7 +350,10 @@ function BlockList( { filterValue, styleFilter }: BlockListProps ) {
role="list"
>
{ filteredBlockTypes.length === 0 ? (
<EmptyBlockList styleFilter={ styleFilter } />
<EmptyBlockList
filterValue={ filterValue }
styleFilter={ styleFilter }
/>
) : (
filteredBlockTypes.map( ( block ) => (
<BlockMenuItem
Expand Down
13 changes: 11 additions & 2 deletions packages/global-styles-ui/src/test/screen-block-list.js
Original file line number Diff line number Diff line change
Expand Up @@ -229,13 +229,22 @@ describe( 'getUserStylesSummary', () => {
).toBe( 'Colors' );
} );

it( 'returns an empty string when no category can be named', () => {
// Border is a real user change, but the changelist does not report it.
it( 'names a border change', () => {
const user = {
styles: {
blocks: { 'core/quote': { border: { width: '2px' } } },
},
};
expect( getUserStylesSummary( user, 'core/quote' ) ).toBe( 'Border' );
} );

it( 'returns an empty string when no category can be named', () => {
// Custom CSS is a real user change that the changelist does not report.
const user = {
styles: {
blocks: { 'core/quote': { css: 'color: red;' } },
},
};
expect( getUserStylesSummary( user, 'core/quote' ) ).toBe( '' );
} );
} );