Fix category filter bug and add tab accessibility
The category tabs were not filtering because the generic tab event handler was overwriting currentFilter with undefined (category tabs use data-category not data-filter). Fixed by targeting only [data-filter] tabs and clearing categoryFilter when switching to non-category tabs. Added proper ARIA attributes for screen reader accessibility: - role="tablist" on nav-tabs container - role="tab" and aria-selected on all tab buttons - Dynamic aria-selected updates on tab clicks Also includes API support for category field and deploy script update. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
18
api.php
18
api.php
@@ -229,24 +229,26 @@ switch ($action) {
|
||||
|
||||
$name = sanitize($input['name'] ?? '');
|
||||
$container = sanitize($input['container'] ?? 'glass-bail-medium', 50);
|
||||
$category = sanitize($input['category'] ?? 'other', 50);
|
||||
$outOfStock = (bool)($input['outOfStock'] ?? false);
|
||||
|
||||
if (empty($name)) {
|
||||
echo json_encode(['success' => false, 'error' => 'Name required']);
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
$inventory = loadInventory();
|
||||
$newItem = [
|
||||
'id' => getNextId($inventory),
|
||||
'name' => $name,
|
||||
'container' => $container,
|
||||
'category' => $category,
|
||||
'outOfStock' => $outOfStock
|
||||
];
|
||||
|
||||
|
||||
$inventory[] = $newItem;
|
||||
saveInventory($inventory);
|
||||
|
||||
|
||||
echo json_encode(['success' => true, 'item' => $newItem]);
|
||||
break;
|
||||
|
||||
@@ -259,31 +261,33 @@ switch ($action) {
|
||||
$id = (int)($input['id'] ?? 0);
|
||||
$name = sanitize($input['name'] ?? '');
|
||||
$container = sanitize($input['container'] ?? '', 50);
|
||||
$category = sanitize($input['category'] ?? '', 50);
|
||||
$outOfStock = (bool)($input['outOfStock'] ?? false);
|
||||
|
||||
if ($id <= 0) {
|
||||
echo json_encode(['success' => false, 'error' => 'Invalid ID']);
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
$inventory = loadInventory();
|
||||
$found = false;
|
||||
|
||||
|
||||
foreach ($inventory as &$item) {
|
||||
if ($item['id'] === $id) {
|
||||
if (!empty($name)) $item['name'] = $name;
|
||||
if (!empty($container)) $item['container'] = $container;
|
||||
if (!empty($category)) $item['category'] = $category;
|
||||
$item['outOfStock'] = $outOfStock;
|
||||
$found = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (!$found) {
|
||||
echo json_encode(['success' => false, 'error' => 'Item not found']);
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
saveInventory($inventory);
|
||||
echo json_encode(['success' => true]);
|
||||
break;
|
||||
|
||||
Reference in New Issue
Block a user