Skip to content

fix(pantry): let the Add item form create a new section - #629

Open
LeMyst wants to merge 1 commit into
cooklang:mainfrom
LeMyst:fix/pantry-new-section
Open

LeMyst wants to merge 1 commit into
cooklang:mainfrom
LeMyst:fix/pantry-new-section

Conversation

@LeMyst

@LeMyst LeMyst commented Oct 5, 2026

Copy link
Copy Markdown
Collaborator

Closes #628

Problem

Since 08233b7 (#293), the Section list in the pantry's Add item dialog only lists the sections already in pantry.conf once the pantry has an item. With a single [fridge] section, every new item had to go to the fridge.

Change

  • The Section list keeps its current entries (the existing sections, or the defaults when the pantry is empty) and gains a last New section… choice. Picking it reveals a "New section name" field, which becomes required and takes focus. If the name is blank, the dialog shows an error instead of sending the request.
  • Section names can now be typed freely, so the item update/remove requests encode the section in the URL (/api/pantry/Wine%20cellar/Merlot). The selector that runs after a removal escapes it with CSS.escape.
  • pantry-section-new and pantry-section-new-name are added in all 9 locales.

The server already created a missing section on POST /api/pantry/add, so there is no Rust change.

Add item dialog with New section… selected and a New section name field

Testing

  • cargo fmt --check, cargo clippy --all-targets (no warnings), cargo test (all pass, including locales_test)
  • Playwright (Chromium) against a pantry with only [fridge]:
    • The list shows fridge and New section…. The name field is hidden until "New section…" is picked.
    • Adding Merlot to "Wine cellar" writes ["Wine cellar"] to pantry.conf, and the page shows both sections.
    • Picking fridge still works, and the field stays hidden.
    • Removing Merlot calls DELETE /api/pantry/Wine%20cellar/Merlot, which returns 200.

🤖 Generated with Claude Code

Since 08233b7 the Section list in the Add item dialog only offers the
sections already in pantry.conf once the pantry has an item, so a second
section could never be created from the web UI.

Add a "New section…" choice that reveals a field for its name. The
server already creates a missing section on add.

Typed section names can now hold spaces, slashes or accents, so encode
the section in the item update/remove URLs and escape it in the
selector used after a removal.

Closes cooklang#628

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@LeMyst
LeMyst marked this pull request as ready for review October 5, 2026 21:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Pantry Add item dialog can't create a new section once the pantry has items

1 participant