Skip to content
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

Trim input text #1391

Merged
merged 2 commits into from
Dec 6, 2024
Merged

Trim input text #1391

merged 2 commits into from
Dec 6, 2024

Conversation

CalebPena
Copy link
Collaborator

What (if any) features are you implementing?

  • Trim the user entered text.

I also removed the white space for the other referrer, as I can't think of a reason it would be useful to store the whitespace the user entered.

@@ -50,27 +61,19 @@ export const ZipcodeStep = () => {
});

const currentZipcodeValue = watch('zipcode');
const shouldShowCountyInput = zipcodeSchema.safeParse(currentZipcodeValue).success;
const parsedZipCode = zipcodeSchema.safeParse(currentZipcodeValue);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What do you think about using the original expression? It seems more readable and explicit in terms of why the parsed zip code is being used.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This fixes a TS error, and allows us to use the parsed zip code in multiple places.

@@ -164,7 +167,7 @@ export const ZipcodeStep = () => {
id="questions.zipcode-a-disabledSelectMenuItemText"
defaultMessage="Select a county"
/>,
countiesByZipcode[watch('zipcode')],
countiesByZipcode[parsedZipCode.data],
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What do you think about using the original expression? I understand that there are performance trade offs with using watch in line, but it's more readable and explicit in terms of what the zipcode value is.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The new way, removes the spaces, so that we don't get a key error.

Copy link
Collaborator

@ivonne-hernandez ivonne-hernandez left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please see the comments regarding some of the refactored Zipcode variables and expressions.

@CalebPena CalebPena merged commit 9c926e6 into dev Dec 6, 2024
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants