department-of-veterans-affairs / vets-design-system-documentation

Repository for design.va.gov website
https://design.va.gov
60 stars 64 forks source link

VaMemorableDateField component populating incorrect default error messaging when onBlur event occurs. #3207

Open jordanBoardmanCodes opened 2 months ago

jordanBoardmanCodes commented 2 months ago

Bug Report

What happened

When entering in a date prior to January 1, 1900 for both Date of birth and Date of death, validation message says 2124 when the year should be 2024.

Here is the Jira ticket that thoroughly explains the issue using PMC as an example. https://jira.devops.va.gov/browse/MBMS-68444

https://github.com/user-attachments/assets/aaf98f8e-376b-4e39-8997-25e7a0e644b1

Reproducing

Steps to reproduce:

https://staging.va.gov/burials-memorials/memorial-items/presidential-memorial-certificates/request-certificate-form-40-0247/veteran-personal-information Navigate to 1 of 10 Veteran's or Reservists Personal Information. For both Date of birth and Date of death enter in January 1, 1899 Click away so validation message displays Validation message : Please enter a year between 1900 and 2124 Note: Prior to clicking away after entering the year it displays correctly 2024, only will it go to 2124 when clicking away.

Expected results: Please enter a year between 1900 and 2024

Actual Results: Please enter a year between 1900 and 2124 Steps to reproduce:

Urgency

How urgent is this request? Please select the appropriate option below and/or provide details

Details to note

This bug was also found in this portion of the app, which indicates it could be something that exists in multiple places. https://staging.va.gov/decision-reviews/supplemental-claim/file-supplemental-claim-form-20-0995/add-issue?index=0

This slack thread also includes info with potential fix information

https://dsva.slack.com/archives/CBU0KDSB1/p1724166207805419

ataker commented 2 months ago

@MichelleDieudonne For visibility

MichelleDieudonne commented 2 months ago

@ataker We are going to mark our internal bug as a 3rd Party fix and will track the progress of this ticket, so thank you for including me! For our internal records, is there ETA for when this item is scheduled to be picked up?

caw310 commented 2 months ago

@MichelleDieudonne We will try to get to this in October. The next few sprints are booked up.

ataker commented 2 months ago

Our error message logic in va-memorable-date is a little complicated currently. We recently updated it to be able to override the default errors, but it's confusing to implement and the documentation is lacking.

Here's different ways that va-memorable-date can show an error:

  1. If the prop invalidDay is set to true, it will check the prop customDayErrorMessage and display that message
  2. Same thing but with the props invalidMonth and customMonthErrorMessage
  3. Same thing but with the props invalidYear and customYearErrorMessage
  4. If va-memorable-date runs it's internal validation and finds an error it will display that message
  5. If the prop error has anything set it will display that message

The component only displays one error at a time and will usually display in that order of precedence, but because step 4 does validation, it can overwrite invalidDay, invalidMonth and invalidYear, therefore taking precedence and removing developer control from the component.

We need to find a solution that allows external errors being sent to the component to have precedence over internal errors. If we end up changing how internal validation works, we may need to also update va-date as it shares utility functions with va-memorable-date.

caw310 commented 2 months ago

Hey team! Please add your planning poker estimate with Zenhub @Andrew565 @ataker @harshil1793 @it-harrison @jamigibbs @micahchiang @powellkerry @rmessina1010 @rsmithadhoc