feat(items): edit quantity and notes inline, with swipe feedback
The PATCH endpoint now also accepts notes. Swiping an item to the left (or right-clicking it) opens an inline editor below the row for its quantity and notes, focused on the quantity input, instead of the quantity dialog. The row slides with the finger during the swipe and snaps back on release, and only one row edits at a time. Toggling an item no longer moves the focus to the add-item input, and notes show under the item's name. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -5,12 +5,14 @@ import { Card } from '@/components/ui/card'
|
||||
import { Collapsible, CollapsibleContent, CollapsibleTrigger } from '@/components/ui/collapsible'
|
||||
import type { useUpdateItem } from '@/hooks/use-items'
|
||||
|
||||
import { ItemRow } from './item-row'
|
||||
import { ItemRow, type ItemRowProps } from './item-row'
|
||||
|
||||
type BoughtItemListProps = {
|
||||
items: ListItem[]
|
||||
updateItem: ReturnType<typeof useUpdateItem>
|
||||
savingIds: string[]
|
||||
/** The editing state of each row, owned by the parent so only one row edits at a time. */
|
||||
editingProps: (itemId: string) => Pick<ItemRowProps, 'editing' | 'onEditingChange'>
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -18,7 +20,12 @@ type BoughtItemListProps = {
|
||||
* marking an item visibly moves it down; the user can fold it. Tapping an item
|
||||
* here un-buys it and it returns to the pending list.
|
||||
*/
|
||||
export function BoughtItemList({ items, updateItem, savingIds }: BoughtItemListProps) {
|
||||
export function BoughtItemList({
|
||||
items,
|
||||
updateItem,
|
||||
savingIds,
|
||||
editingProps,
|
||||
}: BoughtItemListProps) {
|
||||
return (
|
||||
<Collapsible defaultOpen asChild>
|
||||
<Card className="gap-0 py-0">
|
||||
@@ -34,6 +41,7 @@ export function BoughtItemList({ items, updateItem, savingIds }: BoughtItemListP
|
||||
item={item}
|
||||
updateItem={updateItem}
|
||||
isSaving={savingIds.includes(item.id)}
|
||||
{...editingProps(item.id)}
|
||||
/>
|
||||
))}
|
||||
</ul>
|
||||
|
||||
Reference in New Issue
Block a user