Skip to content

Commit

Permalink
Keep Categories in the dropdown
Browse files Browse the repository at this point in the history
  • Loading branch information
ockham committed Sep 18, 2024
1 parent 6a8c539 commit 9f70db6
Showing 1 changed file with 18 additions and 23 deletions.
41 changes: 18 additions & 23 deletions packages/block-library/src/categories/edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,11 +46,7 @@ export default function CategoriesEdit( {
'taxonomy'
);

const taxonomies = allTaxonomies?.filter(
( t ) =>
t.visibility.public &&
( taxonomySlug === 'category' ) === ( t.slug === 'category' )
);
const taxonomies = allTaxonomies?.filter( ( t ) => t.visibility.public );

const taxonomy = taxonomies?.find( ( t ) => t.slug === taxonomySlug );

Expand Down Expand Up @@ -189,24 +185,23 @@ export default function CategoriesEdit( {
<TagName { ...blockProps }>
<InspectorControls>
<PanelBody title={ __( 'Settings' ) }>
{ taxonomySlug !== 'category' && // For back-compat, the Category taxonomy has its own block variation.
Array.isArray( taxonomies ) && (
<SelectControl
__nextHasNoMarginBottom
__next40pxDefaultSize
label={ __( 'Taxonomy' ) }
options={ taxonomies.map( ( t ) => ( {
label: t.name,
value: t.slug,
} ) ) }
value={ taxonomySlug }
onChange={ ( selectedTaxonomy ) =>
setAttributes( {
taxonomy: selectedTaxonomy,
} )
}
/>
) }
{ Array.isArray( taxonomies ) && (
<SelectControl
__nextHasNoMarginBottom
__next40pxDefaultSize
label={ __( 'Taxonomy' ) }
options={ taxonomies.map( ( t ) => ( {
label: t.name,
value: t.slug,
} ) ) }
value={ taxonomySlug }
onChange={ ( selectedTaxonomy ) =>
setAttributes( {
taxonomy: selectedTaxonomy,
} )
}
/>
) }
<ToggleControl
__nextHasNoMarginBottom
label={ __( 'Display as dropdown' ) }
Expand Down

0 comments on commit 9f70db6

Please sign in to comment.