Skip to content

Commit

Permalink
Fix bug where typed values did not show up
Browse files Browse the repository at this point in the history
  • Loading branch information
louwie17 committed Apr 13, 2023
1 parent 4251ebe commit b0d4568
Showing 1 changed file with 10 additions and 2 deletions.
Expand Up @@ -23,6 +23,14 @@ declare const wc_product_category_metabox_params: {
search_categories_nonce: string;
};

function getCategoryTermLabel( item: CategoryTerm | null ): string {
return item?.name || '';
}

function getCategoryTermKey( item: CategoryTerm | null ): string {
return String( item?.term_id );
}

export const CategoryAddNew: React.FC< {
selected: CategoryTerm[];
onChange: ( selected: CategoryTerm[] ) => void;
Expand Down Expand Up @@ -150,8 +158,8 @@ export const CategoryAddNew: React.FC< {
selected={ categoryParent || null }
placeholder={ __( 'Find category', 'woocommerce' ) }
onSelect={ setCategoryParent }
getItemLabel={ ( item ) => item?.name || '' }
getItemValue={ ( item ) => String( item?.term_id ) }
getItemLabel={ getCategoryTermLabel }
getItemValue={ getCategoryTermKey }
onRemove={ () => setCategoryParent( undefined ) }
/>
<input
Expand Down

0 comments on commit b0d4568

Please sign in to comment.