Woocommerce-services: We should validate fields in the modal before leaving the modal

Created on 6 May 2016  路  6Comments  路  Source: Automattic/woocommerce-services

we-really-should-validate-while-in-the-modal

cc @kellychoffman - do you concur?

[Type] Bug

Most helpful comment

@jeffstieler and I just discussed this. We agreed that:

  • We'll have client side validation for the package to be able to show inline errors
  • We'll also have server side validation for packages. Most users won't encounter this (since they'll hit client side validation first), but we'll need to be safe. Any returned errors from the server can highlight the package in question with a message to go and fix that package. We can then show the specific error in the modal. We'll need some design for this @kellychoffman

All 6 comments

@jeffstieler and I just discussed this. We agreed that:

  • We'll have client side validation for the package to be able to show inline errors
  • We'll also have server side validation for packages. Most users won't encounter this (since they'll hit client side validation first), but we'll need to be safe. Any returned errors from the server can highlight the package in question with a message to go and fix that package. We can then show the specific error in the modal. We'll need some design for this @kellychoffman

do you concur?

I do indeed.

We'll also have server side validation for packages. Most users won't encounter this (since they'll hit client side validation first), but we'll need to be safe. Any returned errors from the server can highlight the package in question with a message to go and fix that package.

Can you better explain this? Maybe with an example? I'm not sure I fully understand.

Can you better explain this? Maybe with an example? I'm not sure I fully understand.

Yeah sorry, re-reading myself I see that it's not 100% clear.

In other words: when you add/edit a package we'll have instant client-side validation so you can immediately see any errors. We can disable the "add package"/"save changes" button until validation passes. However, we'll also need/have server-side validation which occurs after one clicks the main "Save changes" button of the form. Most users will have failed client validation so won't trigger an error with packages at this stage, but if they do, we'll need something to indicate which of the already saved boxes has an issue they need to address.

Does that make sense?

Here's what I'm thinking:

We disable the 'Add packages' button until all the required fields are filled out. This way no packages will get added unless they are valid. In theory, anyway. When I was talking to @jeffstieler earlier, he mentioned it might be a good idea to plan for this anyways.

Add packages modal

On open:
(disabled primary button)

screen shot 2016-05-16 at 7 46 39 pm

With error:
(contextual error message, primary button still disabled)

screen shot 2016-05-16 at 7 55 22 pm

All good:
(primary button actived)
screen shot 2016-05-16 at 4 08 34 pm

Package list

With error:
(Click to open modal and fix)

screen shot 2016-05-16 at 8 13 40 pm

Error state for rates section:

screen shot 2016-05-17 at 11 15 15 am

Was this page helpful?
0 / 5 - 0 ratings

Related issues

stephhjacq picture stephhjacq  路  4Comments

nabsul picture nabsul  路  3Comments

allendav picture allendav  路  4Comments

c-shultz picture c-shultz  路  5Comments

jobthomas picture jobthomas  路  4Comments