SFDigitalServices / formio-sfds

The form.io theme for sf.gov
https://formio-sfds.herokuapp.com/
MIT License
15 stars 2 forks source link

Address component schemas are difficult to control #126

Closed shawnbot closed 3 years ago

shawnbot commented 4 years ago

So, we have a pretty hairy problem with the address component. It's complicated, and the behavior of the component differs pretty greatly depending on how the component was added to the form.

So, here's how this is breaking right now:

  1. Forms that got address components from our custom schema on the form.io portal are "locked in" to whatever default schema was defined in the version of our theme that we told the portal to load (most recently, 6.1.0).
  2. Forms that use the built-in address component have a schema that includes a Country field between state and ZIP code, and none of the fields are required.

Neither of these is doing the right thing, because the schema that they were locked into doesn't include the right customClass fields that get the spacing right. #125 was intended to fix vertical spacing between the city and ZIP inputs on smaller screens, but only works for our example components; any form with the components locked in ignores the custom classes we've updated in the default schema.

The other thing that's complicated is deciding when to "customize" the address component:

There are a couple of different ways that we can fix this, but they all have positives and negatives. I'll enumerate those in a bit, but I wanted to get this down for now and reach out to the form.io folks for some advice before embarking on a solution.

shawnbot commented 4 years ago

Okay, I've mulled this over and here are a couple of things that I think we (I) need to do, in approximately this order:

  1. Audit our existing forms for existing address components: both ones with the address type and the ones that our custom address component classes (via different versions of our theme) have generated. (Until recently, the component class was generating container components that the form.io portal doesn't treat as "address" types.)

  2. Bring the design (content, data, and visual) of our ideal address component to the forms working group and hammer out how it should really work: which fields it needs, which ones are required, and potential customizations that it might require for individual forms.

  3. Write a thorough test suite for address inputs that ensures it behaves as we expect it. We should consider integration tests with form.io that ensure the roundtrip from portal/builder → server → client/renderer doesn't change its behavior.

  4. Rebuild our custom address component to pass the tests and any additional QA.

  5. Update (some? all?) existing address fields to use our new component.

shawnbot commented 4 years ago

Some todos from a chat with @sashax, @hshaosf, and @josh-chou:

shawnbot commented 3 years ago

I'm going to close this, as we've got a new setup for shared components documented here:

https://sfgovdt.jira.com/wiki/spaces/DS/pages/2272952651/Shared+components