Repository navigation
Non-USA address state text box and smarter new-address defaults - #2843
Merged
Merged
Conversation
Canadian addresses stored "CA" for Canada rendered as California in the US-only dropdown, with no way to enter a province. Non-USA addresses now get a text box; admins can force one with admin=true to fix US-looking values. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
A second address abroad shouldn't make the person re-pick their country, and the state field and locality should follow it. Country is required only on the person/org forms so imports and registration capture keep saving. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
…address's country A second address usually shares the first one's country, state, and locality, and with nothing saved the organization's own country is the better guess than a hard-coded US. Country stays optional for now. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
maebeale
marked this pull request as ready for review
October 25, 2026 11:05
…e address
Review turned up three things the form got wrong. A blank locality reinvented the
locality rules, so a state no US state answers to ("ON" with no country) was offered
as Outside CA where AddressLocality deliberately declines to guess; delegating to it
also recovers the LA City / LA County / Orange County answers the form was throwing
away. A new address seeded itself from a retired address as readily as a live one,
and the primary flag it preferred is pre-checked on every address added, so it
rarely pointed at the current one — active first, then most recently updated. And
the country hint still told people to pick one after the requirement was reverted.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Pre-filling a new block's country, state and locality from the saved address made an untouched "Add address" block look filled to the nested-attributes reject_if, which slices all five of locality, city, state, street_address and zip_code. The block was built instead of dropped, and the parent save failed on "Addresses city can't be blank" — an organization form could no longer be saved after someone opened an address block and changed their mind. Reject on the three fields a person actually has to type. The other three arrive pre-filled, so they say nothing about whether anyone touched the block, and an address holding only those can never pass validation anyway. Both models carried the same proc, so the list lives on Address with the comment explaining it. While there, point GeographyHelper and AddressTranslation at Address::DEFAULT_COUNTRY so the dropdown's spelling of the US is written once — a value that drifts from the option string renders the select blank. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
🤖 suggested review level: 3 Read 📖 small view/decorator logic shared by person and org address forms, plus a nested-attributes reject rule
Canadian addresses saved as "CA" (Canada) showed up as California with no way to enter a province — non-USA addresses now get a State text box, and new addresses start from the saved one.
What is the goal of this PR and why is this important?
How did you approach the change?
?admin=truegives them the text box on any address (AddressPolicy#enter_any_state?).primaryflag is pre-checked on every address added, so it can't pick the current one.Setting.default_address_country), else United States.AddressLocalitysettles from the address (Outside USA, Outside CA, LA City, LA County, Orange County), blank when it can't guess.AddressDecorator; one sharedaddresses/_state_fieldpartial; no JS.An empty address block has to stay droppable
reject_if, so the block was built and the parent save died on "Addresses city can't be blank".reject_ifnow checks onlycity,street_address,zip_code(Address.unfilled_attributes?) — the fields someone types. Person and Organization shared one copy of the old proc.Address::DEFAULT_COUNTRYis now the only place "United States" is written;GeographyHelperandAddressTranslationpoint at it. A spelling that drifts from the option string renders the select blank.Features seed (optional)
UI Testing Checklist
?admin=true→ text box on a US addressAnything else to add?
?admin=truein the meantime.🤖 Generated with Claude Code