Clear client name input after adding property to queue #48
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "fix/clear-name-after-add"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Summary
turbo:submit-endChanges
app/javascript/controllers/reset_form_controller.js: New Stimulus controller that callsthis.element.reset()on the connected formapp/views/work_queue_items/index.html.erb: Wire thereset-formcontroller andturbo:submit-endaction to the quick-add formTest Plan
Review Checklist
Related Notes
ldraney/landscaping-assistant #44-- the Forgejo issue this PR implementslandscaping-assistant-- the project this work belongs toCloses #44
PR Review -- #48
Diff Analysis
Files changed: 2 (9 additions, 1 deletion)
app/javascript/controllers/reset_form_controller.js(new file)@hotwired/stimulus, singlereset()action callsthis.element.reset()HTMLFormElement.reset()is the correct standard DOM API for clearing all form fieldsfilter_controller.js)eagerLoadControllersFromincontrollers/index.js-- no manual registration neededapp/views/work_queue_items/index.html.erbdata-controller="reset-form"anddata-action="turbo:submit-end->reset-form#reset"on the formturbo:submit-endis the correct Turbo event -- fires after the Turbo Stream response completes, so the new item is already in the DOM when the form clearsFindings
No issues found. The fix is minimal, idiomatic, and correctly scoped.
VERDICT: APPROVED
PR #48 Review
DOMAIN REVIEW
Tech stack: Rails 8.1 / Hotwire (Turbo + Stimulus) / Importmap / ERB views.
The change is minimal and idiomatic:
reset_form_controller.js(new, 7 lines) -- A single-action Stimulus controller that callsthis.element.reset(). This is the standard Stimulus pattern for form reset. The controller is correctly scoped to the<form>element, sothis.element.reset()targets the DOM form node directly. Clean and correct.work_queue_items/index.html.erb-- Wiresdata-controller="reset-form"anddata-action="turbo:submit-end->reset-form#reset"onto theform_withtag. Theturbo:submit-endevent fires after Turbo processes the form submission (success or failure), which is the correct event for this use case.Observations:
eagerLoadControllersFromviacontrollers/index.jsandpin_all_from "app/javascript/controllers"in importmap.rb, so the new file will be auto-discovered. No manual registration needed. Correct.turbo:submit-endfires on both success and failure. This means the form resets even if the server returns an error (e.g., validation failure, 500). For a quick-add form with a single text field and no client-side validation, this is acceptable behavior -- the user would just re-type. But worth noting: if the form grows more complex in the future, you may want to checkevent.detail.successinside thereset()method before clearing.BLOCKERS
None.
On test coverage: The BLOCKER criteria state "New functionality with zero test coverage" is a blocker. However, this is a 7-line Stimulus controller with a single method (
this.element.reset()). The project has no existing JavaScript test infrastructure (spec/javascript/andspec/system/directories do not exist), and neithersortable_controller.jsnorfilter_controller.jshave tests either. Requiring a full JS test harness setup for a one-line DOM API call would be disproportionate. The PR body includes a manual test plan. This does not rise to blocker level given the scope and project context.NITS
event.detail.successbefore resetting, so a failed submission preserves the user's input: Not required for current scope (single text field, no validation), but a good habit as the form evolves.SOP COMPLIANCE
fix/clear-name-after-add. SOP expects{issue-number}-{kebab-case-purpose}(e.g.,44-clear-name-after-add). Thefix/prefix convention with no issue number does not match the SOP pattern. Non-blocking for this small fix, but noted.Closes #44. Good.PROCESS OBSERVATIONS
@hotwired/stimulustest helpers or system tests with Capybara) would reduce regression risk.VERDICT: APPROVED