Fix: Handle items with unmatched categories in showItemsStep
Items were being grouped only by known categories. If the category array was empty or didn't include an item's category, those items never got checkboxes rendered, causing confirmItems() to filter them all out. Now collects unassigned items and groups them by their category name (or 'Menu' as fallback). Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
parent
09e5807c94
commit
682cb41ff1
1 changed files with 20 additions and 1 deletions
|
|
@ -2647,10 +2647,29 @@
|
|||
|
||||
// Group items by category
|
||||
let itemsByCategory = {};
|
||||
let assignedItemIds = new Set();
|
||||
|
||||
categories.forEach(cat => {
|
||||
itemsByCategory[cat.name] = items.filter(item => item.category === cat.name);
|
||||
const catItems = items.filter(item => item.category === cat.name);
|
||||
if (catItems.length > 0) {
|
||||
itemsByCategory[cat.name] = catItems;
|
||||
catItems.forEach(item => assignedItemIds.add(item.id));
|
||||
}
|
||||
});
|
||||
|
||||
// Collect any items not assigned to a known category
|
||||
const unassignedItems = items.filter(item => !assignedItemIds.has(item.id));
|
||||
if (unassignedItems.length > 0) {
|
||||
// Group by their category name, or "Menu" if none
|
||||
unassignedItems.forEach(item => {
|
||||
const catName = item.category || 'Menu';
|
||||
if (!itemsByCategory[catName]) {
|
||||
itemsByCategory[catName] = [];
|
||||
}
|
||||
itemsByCategory[catName].push(item);
|
||||
});
|
||||
}
|
||||
|
||||
let itemsHtml = '';
|
||||
for (const [catName, catItems] of Object.entries(itemsByCategory)) {
|
||||
if (catItems.length === 0) continue;
|
||||
|
|
|
|||
Reference in a new issue