CodeForPhilly / balancer-main

CodeForPhilly balancer project (https://opencollective.com/code-for-philly/projects/balancer)
GNU Affero General Public License v3.0
11 stars 8 forks source link

BUG Submit button on New patient form #100

Open taichan03 opened 3 months ago

taichan03 commented 3 months ago

BUG When users click submit on the New patient form, sometimes they have to click twice. We would like to fix it so that it will work with one click.

Image

katjost commented 2 weeks ago

Anyone can pick this up!

snaeem3 commented 1 week ago

Hi,

I looked into this bug and it seems to be caused by the form not having a value set in the "Current State" field.

If you select an option, the form will submit on the first time. However if you skip it, maybe because 'Manic' is the correct option that you wanted, the form has the value saved as null and then it runs through this code in the handleSubmit function

// Check if Diagnosis is "Null"
if (newPatientInfo.Diagnosis === "Null") {
   newPatientInfo.Diagnosis = "Manic";
   // setErrors(["Please select a current state."]);
   // window.scrollTo({ top: 0, behavior: "smooth" });
   return; // Prevent form submission
}

Solution

I propose 2 options to solve this:

  1. Set Manic or another option as the default, which may have been what the code was trying to do.
  2. Require the user to set a Current State and prevent form submission until an option is selected. See the screenshot below for an idea of what I'm suggesting image

I'm not familiar enough with the application to say which route we should take. Both are fairly easy to implement so please let me know and I would be happy to help.

katjost commented 5 days ago

@snaeem3 you are awesome! Thank you for looking into this and proposing solutions. Let's go with Solution 1. Let's also remove null as an option, in this case.