-
Notifications
You must be signed in to change notification settings - Fork 4.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Show uncategorized patterns on the Editor > Patterns page #52633
Changes from 2 commits
ef82376
4076cfe
3bae60e
31e1f4d
c072115
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,6 +2,7 @@ | |
* WordPress dependencies | ||
*/ | ||
import { useMemo } from '@wordpress/element'; | ||
import { __ } from '@wordpress/i18n'; | ||
|
||
/** | ||
* Internal dependencies | ||
|
@@ -11,6 +12,10 @@ import useThemePatterns from './use-theme-patterns'; | |
|
||
export default function usePatternCategories() { | ||
const defaultCategories = useDefaultPatternCategories(); | ||
defaultCategories.push( { | ||
name: 'uncategorized', | ||
label: __( 'Uncategorized' ), | ||
} ); | ||
Comment on lines
+15
to
+18
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The "uncategorized" category for template parts was changed to "General" as that was the previous labelling. In that feedback, it was mentioned that nowhere else in the UI used "Uncategorized", we might need to change it here as well. cc/ @SaxonF There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Uncategorized is used in several places. For example, when a post does not have a category. It is not a term that is unfamiliar. But I choose it here over "General" because "Uncategorized" is what is used in the pattern inserter. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It made sense to use General for template parts, because that is what is used in the block editor UI for template parts. |
||
const themePatterns = useThemePatterns(); | ||
|
||
const patternCategories = useMemo( () => { | ||
|
@@ -31,6 +36,10 @@ export default function usePatternCategories() { | |
categoryMap[ category ].count += 1; | ||
} | ||
} ); | ||
// If the pattern has no categories, add it to uncategorized. | ||
if ( ! pattern.categories?.length ) { | ||
categoryMap.uncategorized.count += 1; | ||
} | ||
} ); | ||
|
||
// Filter categories so we only have those containing patterns. | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The uncategorized patterns would still need to be filtered via the search term correct?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes you are right, let me see if I can fix that 🤔
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I still don't understand why the search was limited to searching inside categories instead of across all.