Repository navigation
Conversation
Adds an address box above the Representative and Senator pickers, on Edit Profile and on the testimony flow's "Select Your Legislators" step. The browser geocodes the address with MassGIS's statewide geocoder, finds the House and Senate districts in MassGIS's 2021 district layers, and fills both pickers from MAPLE's member search index. The address is not sent to MAPLE's servers or saved. Behind the legislatorAddressLookup flag (on in development, off in production). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01D33UhQEt1gm2oVFCq3FdXf
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
mvictor55
marked this pull request as ready for review
November 24, 2026 16:36
mvictor55
requested review from
Mephistic,
alexjball,
kiminkim724,
mertbagt,
nesanders,
sashamaryl and
timblais
as code owners
November 24, 2026 16:36
Collaborator
|
This looks like it implements an older ticket - #1022 - just leaving that here for context |
This branch was successfully deployed
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.
Summary
MAPLE currently sends people to the legislature's "find your legislator" tool and asks them to come back and pick their representative and senator. This adds an address box above those two pickers, on Edit Profile and on the "Select Your Legislators" step of submitting testimony. Type a home address, press "Find my legislators", and both pickers fill in. The pickers still work by hand, and the link to the legislature's tool stays as a fallback.
How it works (details in docs/legislator-address-lookup.md):
The browser sends the address to MassGIS's statewide geocoder, built on its statewide address points. The matched point is then looked up in MassGIS's official 2021 House and Senate district layers. Both services allow cross-origin requests, so no backend is needed and the address never reaches MAPLE's servers and isn't saved. The note under the box says so.
District names are matched to MAPLE's member search index (districtId from functions/src/districts/normalize.ts). The district layers also carry legislators' names, but those lag behind (one district still reads "Open"), so they aren't used. A district with no member in the index is shown as possibly vacant, and that picker is cleared.
Picking the right match (decideCandidate): the geocoder treats a town that shares its county's name (Worcester, Plymouth, Barnstable, Franklin, …) as matching every town in that county at the same score, and gives Boston addresses their neighborhood as the city. Matches in the town, neighborhood or ZIP code the user typed are therefore preferred. A single exact match is taken. Anything fuzzier (a corrected spelling, a different town) asks "Which of these is your address?". The matched address is always shown.
Behind a new flag, legislatorAddressLookup: on in development (dev site and previews) and off in production.
No new dependencies.
Checklist
[x] On the frontend, I've made my strings translate-able.
[x] If I've added shared components, I've added a storybook story. (The lookup renders inside the existing LegislatorForm story.)
[x] I've made pages responsive and look good on mobile. (Checked at 420px and 375px.)
[x] If I've added new Firestore queries, I've added any new required indexes to firestore.indexes.json. (No new queries.)
Screenshots
To be added: the found state (both pickers filled) and the "Which of these is your address?" state.
Known issues
Depends on MassGIS being up. If it doesn't answer, the user sees a message pointing to the legislature's tool.
Not compared against the legislature's own tool, which sits behind a CAPTCHA. Instead, 27 addresses across the state were run against the live MassGIS services, and the districts returned agreed 27 for 27 with the Census Bureau's 2026 state legislative district layers at the same points.
Redistricting. After the 2030 census, the layer URLs and the district-name fixture will need updating (see the doc).
Storybook shows vacancies. The LegislatorForm story's mock members have the district "District", so a lookup there reports both seats as possibly vacant. That's expected with the mock data.
Extra Deploy Steps
When releasing: set legislatorAddressLookup: true under production in components/featureFlags.ts. Until then the lookup can be tried on production with ?legislatorAddressLookup=enabled.
Steps to test/reproduce
On the preview, sign in and go to Edit Profile.
In "Your Legislators", type 24 Beacon St, Boston and press "Find my legislators". Both pickers fill (8th Suffolk, Third Suffolk) and the matched address is shown.
Try 455 Main St, Worcester. It should match Worcester itself, not other towns in Worcester County.
Try 100 Warren St, Boston. You're asked to choose between Charlestown, Roxbury and Warren Ave; pick one and the pickers fill.
Try 1 Main St, Greenfield. The House seat (1st Franklin) is reported as possibly vacant.
Try Beacon St, Boston (asks for a street number) and 1 Main St, Portland ME (not found).
Start a testimony without legislators set: the same box appears on "Select Your Legislators".
Add ?legislatorAddressLookup=disabled and confirm the old text and link come back.
Checks run: yarn check-types, yarn check-formatting, yarn lint (no warnings in changed files), yarn test:website (47 suites, including the two new ones), yarn test (32 suites).
🤖 Generated with Claude Code
https://claude.ai/code/session_01D33UhQEt1gm2oVFCq3FdXf

