Skip to content
This repository was archived by the owner on Feb 23, 2024. It is now read-only.

Commit adda87f

Browse files
committed
Breadcrumbs should always at least be empty array.
1 parent 4ef263e commit adda87f

File tree

4 files changed

+5
-15
lines changed

4 files changed

+5
-15
lines changed

assets/js/editor-components/product-attribute-term-control/index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ const ProductAttributeTermControl = ( {
6565
},
6666
];
6767

68-
if ( ! item?.breadcrumbs?.length ) {
68+
if ( ! item.breadcrumbs.length ) {
6969
return (
7070
<ExpandableSearchListItem
7171
{ ...args }

assets/js/editor-components/product-tag-control/product-tag-item.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ export const ProductTagItem = ( {
1616
depth = 0,
1717
...rest
1818
}: renderItemArgs ): JSX.Element => {
19-
const accessibleName = ! item?.breadcrumbs?.length
19+
const accessibleName = ! item.breadcrumbs.length
2020
? item.name
2121
: `${ item.breadcrumbs.join( ', ' ) }, ${ item.name }`;
2222

assets/js/editor-components/search-list-control/item.tsx

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -22,22 +22,12 @@ const Count = ( { label }: { label: string | React.ReactNode | number } ) => {
2222
);
2323
};
2424

25-
type SearchListItemPropsWithBreadcrumb = SearchListItemProps & {
26-
breadcrumbs: string[];
27-
};
28-
29-
const checkHasBreadCrumbs = (
30-
item: SearchListItemProps
31-
): item is SearchListItemPropsWithBreadcrumb => {
32-
return !! ( item.breadcrumbs && item.breadcrumbs.length );
33-
};
34-
3525
const ItemLabel = ( props: { item: SearchListItemProps; search: string } ) => {
3626
const { item, search } = props;
3727

3828
return (
3929
<span className="woocommerce-search-list__item-label">
40-
{ checkHasBreadCrumbs( item ) ? (
30+
{ item.breadcrumbs.length ? (
4131
<span className="woocommerce-search-list__item-prefix">
4232
{ getBreadcrumbsForDisplay( item.breadcrumbs ) }
4333
</span>
@@ -69,7 +59,7 @@ export const SearchListItem = ( {
6959
countLabel !== null &&
7060
item.count !== undefined &&
7161
item.count !== null;
72-
const hasBreadcrumbs = !! item.breadcrumbs?.length;
62+
const hasBreadcrumbs = !! item.breadcrumbs.length;
7363
const hasChildren = !! item.children?.length;
7464
const isExpanded = expandedPanelId === item.id;
7565
const classes = classNames(

assets/js/editor-components/search-list-control/types.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ export interface ListItemsProps
3535
}
3636

3737
export type SearchListItem = {
38-
breadcrumbs?: string[];
38+
breadcrumbs: string[];
3939
children?: SearchListItem[];
4040
count: number;
4141
id: string | number;

0 commit comments

Comments
 (0)