Fix: In product list, if menu category is reset, all products get filtered out as it becomes undefined.
This commit is contained in:
@ -71,7 +71,7 @@ export class ProductListDataSource extends DataSource<Product> {
|
|||||||
}),
|
}),
|
||||||
);
|
);
|
||||||
|
|
||||||
const matchesMenuCategory = menuCategory === '' || skus.some((k) => (k.menuCategory?.id ?? '') === menuCategory);
|
const matchesMenuCategory = !menuCategory || skus.some((k) => (k.menuCategory?.id ?? '') === menuCategory);
|
||||||
return matchesSearch && matchesMenuCategory;
|
return matchesSearch && matchesMenuCategory;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
@ -75,9 +75,6 @@ export class ProductListComponent implements OnInit {
|
|||||||
this.menuCategoryFilter.subscribe((val) => {
|
this.menuCategoryFilter.subscribe((val) => {
|
||||||
console.log('Menu category filter changed to ', val);
|
console.log('Menu category filter changed to ', val);
|
||||||
});
|
});
|
||||||
this.searchFilter.subscribe((val) => {
|
|
||||||
console.log('Search filter changed to ', val);
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
filterOn(val: string) {
|
filterOn(val: string) {
|
||||||
|
|||||||
Reference in New Issue
Block a user