Skip to content

Add support for address autocomplete #494

@kydecker

Description

@kydecker

Is your feature request related to a problem? Please describe.

Currently, address entry is manual, and certain forms like the Massachusetts Court Order request a county of residence. Being asked for county is uncommon online, any many people aren't sure what theirs is!

Image

Describe the solution you'd like

We can simplify the entry of addresses and guard against user errors and typos by integrating with an API that allows for address lookup and autocomplete.

After a quick search, @geoapify/geocoder-autocomplete looks promising: it's a lightweight TypeScript package with zero dependencies which relies on a GDPR-compliant API that has a free plan including up to 5 requests per second, which should be more than plenty for our case.

Information about Address Autocomplete: https://www.geoapify.com/address-autocomplete/

We should:

  • Register for Geoapify and set up an account / API key
  • Install and set up the @geoapify/geocoder-autocomplete package
  • Follow the docs to correctly query the API and get back an object containing street address, state, county, zip, etc.
  • Update the streetAddress field of the AddressField component to conduct a search when the API is available, and display results in a combobox/dropdown beneath the input which can be selected with the keyboard.
    • We might need to swap out the TextField for a different component (We already have Autocomplete in the design system, and it can handle asynchronous loading, so it's probably worth reading the React Aria docs for that component)
  • When the API is available and an entry has been selected, fill all address fields with the results from the object returned from the Geoapify API and double-check that filled fields correctly save to IndexedDB
  • Fallback to plain text entry if the Geoapify API is unavailable
  • Write/update unit tests for AddressField to cover new functionality

Describe alternatives you've considered

If Geoapify doesn't end up working, we can explore other providers.

Metadata

Metadata

Assignees

No one assigned

    Labels

    dependenciesPull requests that update a dependency fileenhancementNew feature or request
    No fields configured for Feature.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions