diff --git a/client/src/components/Packing/PackingListPanelCategoryGroup.test.tsx b/client/src/components/Packing/PackingListPanelCategoryGroup.test.tsx index 3bffc1810..f1bb65211 100644 --- a/client/src/components/Packing/PackingListPanelCategoryGroup.test.tsx +++ b/client/src/components/Packing/PackingListPanelCategoryGroup.test.tsx @@ -485,6 +485,17 @@ describe('KategorieGruppe — inline add item', () => { expect(onAddItem).not.toHaveBeenCalled() }) + it('FE-W5CAT-028a: Enter on the first item typed into the placeholder row opens the add field (#2825)', async () => { + server.use(http.put('/api/trips/1/packing/1', () => HttpResponse.json({ item: buildPackingItem({ id: 1, name: 'Tent', category: 'Gear' }) }))) + setup({ items: [buildPackingItem({ id: 1, name: '...', category: 'Gear' })] }) + + fireEvent.click(screen.getByText('...')) + fireEvent.change(screen.getByPlaceholderText('...'), { target: { value: 'Tent' } }) + fireEvent.keyDown(screen.getByPlaceholderText('...'), { key: 'Enter' }) + + await waitFor(() => expect(screen.getByPlaceholderText('Item name...')).toHaveFocus()) + }) + it('FE-W5CAT-028: the confirm button adds the item, and stays inert while empty', () => { const onAddItem = vi.fn(async () => {}) const { container } = setup({ onAddItem }) diff --git a/client/src/components/Packing/PackingListPanelCategoryGroup.tsx b/client/src/components/Packing/PackingListPanelCategoryGroup.tsx index d3f635538..479ce46f6 100644 --- a/client/src/components/Packing/PackingListPanelCategoryGroup.tsx +++ b/client/src/components/Packing/PackingListPanelCategoryGroup.tsx @@ -86,6 +86,7 @@ export function KategorieGruppe({ kategorie, items, tripId, allCategories, onRen const [showAddItem, setShowAddItem] = useState(false) const [newItemName, setNewItemName] = useState('') const addItemRef = useRef(null) + const openAddItem = () => { setShowAddItem(true); setTimeout(() => addItemRef.current?.focus(), 30) } const menuBtnRef = useRef(null) const assigneeDropdownRef = useRef(null) const { togglePackingItem } = useTripStore() @@ -292,7 +293,7 @@ export function KategorieGruppe({ kategorie, items, tripId, allCategories, onRen const contributions = contribFor(item.id) return ( - {}} onDelete={onDeleteItem} bagTrackingEnabled={bagTrackingEnabled} bags={bags} onCreateBag={onCreateBag} canEdit={canEdit} divider={index > 0} + {}} onDelete={onDeleteItem} onPlaceholderFilled={openAddItem} bagTrackingEnabled={bagTrackingEnabled} bags={bags} onCreateBag={onCreateBag} canEdit={canEdit} divider={index > 0} tripMembers={tripMembers} currentUserId={currentUserId} onSetSharing={onSetSharing} onClone={onClone} onJoin={onJoin} onLeave={onLeave} drag={canEdit && reorderable ? { isDragging: dragId === item.id, @@ -343,7 +344,7 @@ export function KategorieGruppe({ kategorie, items, tripId, allCategories, onRen // A row of its own on a faint tint, so it closes the card instead // of trailing off: a dashed box in the checkbox column (past the drag // grip's width) and the label where an item's name sits. -