-
Notifications
You must be signed in to change notification settings - Fork 126
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Handle empty address FormData in AddressWIthAutofillReviewField #29847
Conversation
@@ -5,7 +5,7 @@ import constants from 'vets-json-schema/dist/constants.json'; | |||
export const AddressWithAutofillReviewField = ({ formData, inputLabel }) => { | |||
const stateLabel = constants.states.USA.find( | |||
state => state.value === formData.state, | |||
).label; | |||
)?.label; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is the only functional change in the PR beyond tests. Trying to get the label for an empty or undefined state throws an error without the optional chaining operator here.
inputLabel: 'Primary Family Caregiver\u2019s', | ||
}; | ||
|
||
const subject = (props = defaultProps) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wrapped our render
and getSelectors
calls into a subject and set the defaultProps
on it with the ability to pass in custom props.
...lications/caregivers/tests/components/FormReview/AddressWithAutofillReviewField.unit.spec.js
Show resolved
Hide resolved
...lications/caregivers/tests/components/FormReview/AddressWithAutofillReviewField.unit.spec.js
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍 Looks good!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
Summary
AddressWIthAutofillReviewField
when no state value is provided in theformData
prop.undefined
when trying to look up the state label, but now it will just render it as empty.Related issue(s)
department-of-veterans-affairs/va.gov-team#83332
Testing done
What areas of the site does it impact?
Form 10-10 EZCG
Acceptance criteria
Quality Assurance & Testing
Error Handling
Authentication