Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
18 commits
Select commit Hold shift + click to select a range
6d96049
Block Editor: extract getPopulatedCategories util and expose pattern …
jorgefilipecosta Aug 10, 2026
21a8646
Editor: add category filtering and search to the start page options m…
jorgefilipecosta Aug 10, 2026
21569e6
Add end-to-end coverage for the start page options pattern categories
jorgefilipecosta Aug 10, 2026
3d526de
Add changelog entries
jorgefilipecosta Aug 10, 2026
9357df6
Start Page Options: Keep the whole Tabs tree in the editor package
t-hamano Aug 19, 2026
b70a3a6
Move the changelog entries back to the Unreleased section
jorgefilipecosta Aug 19, 2026
4fef0d3
Show a message when the pattern search has no results
jorgefilipecosta Aug 20, 2026
c653a03
Simplify the uncategorized-only categories check
jorgefilipecosta Aug 20, 2026
b46e9af
Use __ instead of a context-less _x for the Uncategorized label
jorgefilipecosta Aug 31, 2026
788d2b6
Ensure a minimum pattern preview width in the start page and template…
jorgefilipecosta Aug 31, 2026
6970b67
Post-rebase fix: Move the changelog entries back to the Unreleased se…
jorgefilipecosta Sep 10, 2026
e00a310
Read the registered pattern categories from the block editor settings
jorgefilipecosta Sep 14, 2026
eee4676
Style the start page options no-results message
jorgefilipecosta Sep 14, 2026
c552d16
Fall back to all patterns when the selected category disappears
jorgefilipecosta Sep 14, 2026
10e7f09
Post-rebase fix: Reformat with wp-prettier 3.9.6
jorgefilipecosta Sep 16, 2026
d52711b
Keep two pattern columns while the category sidebar is visible
jorgefilipecosta Sep 16, 2026
d4faab8
Note in the changelog that the modal also runs for posts
jorgefilipecosta Sep 16, 2026
410f797
Merge branch 'trunk' into add/start-page-options-pattern-categories
jorgefilipecosta Sep 17, 2026
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
1 change: 1 addition & 0 deletions packages/block-editor/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@

- Block bindings and variation transforms: Use the public `Menu` from `@wordpress/ui` instead of the private Components API. ([#81925](https://github.com/WordPress/gutenberg/pull/81925))
- Layout hooks: Use `normalizeLegacyLayout` in `useLayoutClasses`, `useLayoutStyles`, the block layout styles wrapper and `isAxialBlockGapAllowed`, replacing four inline copies of the legacy `inherit` / size check ([#82710](https://github.com/WordPress/gutenberg/pull/82710)).
- Extract the populated pattern category computation from `usePatternCategories` into a `getPopulatedCategories` util, and expose it and `searchItems` through private APIs for reuse by the start page options modal ([#81396](https://github.com/WordPress/gutenberg/pull/81396)).

## 17.1.0 (2026-09-10)

Expand Down
Original file line number Diff line number Diff line change
@@ -1,25 +1,16 @@
import { useMemo } from '@wordpress/element';
import { _x, _n, sprintf } from '@wordpress/i18n';
import { _n, sprintf } from '@wordpress/i18n';
import { speak } from '@wordpress/a11y';
import usePatternsState from '../hooks/use-patterns-state';
import {
isPatternFiltered,
allPatternsCategory,
myPatternsCategory,
starterPatternsCategory,
getPopulatedCategories,
INSERTER_PATTERN_TYPES,
} from './utils';

function hasRegisteredCategory( pattern, allCategories ) {
if ( ! pattern.categories || ! pattern.categories.length ) {
return false;
}

return pattern.categories.some( ( cat ) =>
allCategories.some( ( category ) => category.name === cat )
);
}

export function usePatternCategories( rootClientId, sourceFilter = 'all' ) {
const [ patterns, allCategories ] = usePatternsState(
undefined,
Expand All @@ -39,27 +30,10 @@ export function usePatternCategories( rootClientId, sourceFilter = 'all' ) {

// Remove any empty categories.
const populatedCategories = useMemo( () => {
const categories = allCategories
.filter( ( category ) =>
filteredPatterns.some( ( pattern ) =>
pattern.categories?.includes( category.name )
)
)
.sort( ( a, b ) => a.label.localeCompare( b.label ) );

if (
filteredPatterns.some(
( pattern ) => ! hasRegisteredCategory( pattern, allCategories )
) &&
! categories.find(
( category ) => category.name === 'uncategorized'
)
) {
categories.push( {
name: 'uncategorized',
label: _x( 'Uncategorized' ),
} );
}
const categories = getPopulatedCategories(
filteredPatterns,
allCategories
);
if (
filteredPatterns.some( ( pattern ) =>
pattern.blockTypes?.includes( 'core/post-content' )
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,50 @@ export const starterPatternsCategory = {
label: __( 'Starter content' ),
};

function hasRegisteredCategory( pattern, allCategories ) {
if ( ! pattern.categories || ! pattern.categories.length ) {
return false;
}

return pattern.categories.some( ( cat ) =>
allCategories.some( ( category ) => category.name === cat )
);
}

/**
* Returns the categories that contain at least one of the given patterns,
* sorted by label. An "Uncategorized" category is appended when some pattern
* belongs to no registered category.
*
* @param {Array} patterns The patterns to derive the categories from.
* @param {Array} allCategories The registered pattern categories.
*
* @return {Array} The populated categories.
*/
export function getPopulatedCategories( patterns, allCategories ) {
const categories = allCategories
.filter( ( category ) =>
patterns.some( ( pattern ) =>
pattern.categories?.includes( category.name )
)
)
.sort( ( a, b ) => a.label.localeCompare( b.label ) );

if (
patterns.some(
( pattern ) => ! hasRegisteredCategory( pattern, allCategories )
) &&
! categories.find( ( category ) => category.name === 'uncategorized' )
) {
categories.push( {
name: 'uncategorized',
label: __( 'Uncategorized' ),
} );
}

return categories;
}

export function isPatternFiltered( pattern, sourceFilter, syncFilter ) {
const isUserPattern = pattern.name.startsWith( 'core/block' );
const isDirectoryPattern =
Expand Down
4 changes: 4 additions & 0 deletions packages/block-editor/src/private-apis.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@ import {
extractWords,
getNormalizedSearchTerms,
normalizeString,
searchItems,
} from './components/inserter/search-items';
import { getPopulatedCategories } from './components/inserter/block-patterns-tab/utils';
import { PrivateListView } from './components/list-view';
import InspectorControlsLastItem from './components/inspector-controls/last-item';
import { useHasBlockToolbar } from './components/block-toolbar/use-has-block-toolbar';
Expand Down Expand Up @@ -161,4 +163,6 @@ lock( privateApis, {
useNativeUndo,
usesNativeUndo,
isElementVisible,
getPopulatedCategories,
searchItems,
} );
64 changes: 64 additions & 0 deletions packages/e2e-tests/plugins/starter-page-patterns.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
<?php
/**
* Plugin Name: Gutenberg Test Starter Page Patterns
* Plugin URI: https://github.com/WordPress/gutenberg
* Author: Gutenberg Team
*
* @package gutenberg-test-starter-page-patterns
*/

register_block_pattern_category(
'test-about',
array( 'label' => 'Test About' )
);
register_block_pattern_category(
'test-services',
array( 'label' => 'Test Services' )
);
register_block_pattern_category(
'test-post-only',
array( 'label' => 'Test Post Only' )
);

register_block_pattern(
'starter-page-patterns/about',
array(
'title' => 'About page',
'categories' => array( 'test-about' ),
'blockTypes' => array( 'core/post-content' ),
'postTypes' => array( 'page' ),
'content' => '<!-- wp:heading --><h2 class="wp-block-heading">About us</h2><!-- /wp:heading --><!-- wp:paragraph --><p>We build websites.</p><!-- /wp:paragraph -->',
)
);

register_block_pattern(
'starter-page-patterns/services',
array(
'title' => 'Services page',
'categories' => array( 'test-services' ),
'blockTypes' => array( 'core/post-content' ),
'postTypes' => array( 'page' ),
'content' => '<!-- wp:heading --><h2 class="wp-block-heading">Our services</h2><!-- /wp:heading -->',
)
);

register_block_pattern(
'starter-page-patterns/no-category',
array(
'title' => 'Plain page',
'blockTypes' => array( 'core/post-content' ),
'postTypes' => array( 'page' ),
'content' => '<!-- wp:paragraph --><p>A plain start.</p><!-- /wp:paragraph -->',
)
);

register_block_pattern(
'starter-page-patterns/post-only',
array(
'title' => 'Post call to action',
'categories' => array( 'test-post-only' ),
'blockTypes' => array( 'core/post-content' ),
'postTypes' => array( 'post' ),
'content' => '<!-- wp:paragraph --><p>Posts only.</p><!-- /wp:paragraph -->',
)
);
1 change: 1 addition & 0 deletions packages/editor/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
- Remove the `react-autosize-textarea` dependency. The post editor's "Code editor" view now auto-grows with CSS `field-sizing: content`. Browsers without support use a scrollable field ([#64208](https://github.com/WordPress/gutenberg/pull/64208)).
- `PostTaxonomiesFlatTermSelector`: The field renders with the `SearchableChipSelectControl` component of `@wordpress/ui` instead of `FormTokenField` ([#80967](https://github.com/WordPress/gutenberg/pull/80967)).
- `CollaboratorsPresence`: Show focus ring for avatar stack in header with button's outline instead of previous box-shadow override ([#82941](https://github.com/WordPress/gutenberg/pull/82941)).
- Add category filtering and search to the "Choose a pattern" modal shown when creating a new page or post. Only the categories containing start patterns for the current post type are listed, with labels pulled from the registered pattern categories ([#81396](https://github.com/WordPress/gutenberg/pull/81396)).

### Bug Fixes

Expand Down
Loading
Loading