Clear the Add Location form after each add #207

Merged
claude-bot merged 1 commit from fix/location-form-reset into main 2026-10-13 17:40:26 +00:00
Collaborator

Reported by @rbrooks on dev (rc5), 2026-10-13, while adding three locations in a row: the name box was blank for the first, then held the previous location's name each time after, and the minimum severity did not reset either.

Cause

submitAddLocation closes the dialog and calls window.location.reload() on success. Browsers restore form field values across a reload, so the form reopened with the last submission's name, severity, search text and coordinates.

It is worse than cosmetic: the search box only auto-fills the name when the name field is blank, so with a leftover name the pin moves to the new place while the name stays the old one. A second location can be saved under the first one's name.

Fix

  • resetAddLocationForm() runs before the reload: form.reset(), hides the error, removes the map pin and returns the map to the national view.
  • The form is marked autocomplete="off" so the browser does not restore it.
  • The add-channel and AI-provider forms follow the same add-then-reload pattern and hold webhook URLs, tokens and API keys. They get autocomplete="off" too.

Verification

  • ruff: clean
  • Bulk tier: 1012 passed (1 new)
  • Not verified in a browser. None is available in this session, and browser form restoration is exactly the behaviour at issue, so this wants a check on dev: add two locations in a row and confirm the second opens blank with Watch selected.

Ships in v2.0.0-rc6.

🤖 Generated with Claude Code

Reported by @rbrooks on dev (rc5), 2026-10-13, while adding three locations in a row: the name box was blank for the first, then held the previous location's name each time after, and the minimum severity did not reset either. ## Cause `submitAddLocation` closes the dialog and calls `window.location.reload()` on success. Browsers restore form field values across a reload, so the form reopened with the last submission's name, severity, search text and coordinates. It is worse than cosmetic: the search box only auto-fills the name when the name field is blank, so with a leftover name the pin moves to the new place while the name stays the old one. A second location can be saved under the first one's name. ## Fix - `resetAddLocationForm()` runs before the reload: `form.reset()`, hides the error, removes the map pin and returns the map to the national view. - The form is marked `autocomplete="off"` so the browser does not restore it. - The add-channel and AI-provider forms follow the same add-then-reload pattern and hold webhook URLs, tokens and API keys. They get `autocomplete="off"` too. ## Verification - ruff: clean - Bulk tier: **1012 passed** (1 new) - **Not verified in a browser.** None is available in this session, and browser form restoration is exactly the behaviour at issue, so this wants a check on dev: add two locations in a row and confirm the second opens blank with Watch selected. Ships in v2.0.0-rc6. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
Clear the Add Location form after each add
All checks were successful
CI / test (pull_request) Successful in 6m47s
56b162dbb1
Adding several locations in a row reopened the form with the previous
location's name and minimum severity. The page reloads after a successful
add, and browsers restore form values across a reload. The leftover name
also defeated the search box's name auto-fill, which only fills a blank
field, so a second location could be saved under the first one's name.

The form is now reset (fields, error, map pin and view) before the reload,
and marked autocomplete="off" so the browser does not restore it.

The add-channel and AI-provider forms follow the same add-then-reload
pattern and hold credentials, so they get autocomplete="off" as well.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
rbrooks/WeatherBot!207
No description provided.