-
Notifications
You must be signed in to change notification settings - Fork 4
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
Trim input text #1391
Conversation
@@ -50,27 +61,19 @@ export const ZipcodeStep = () => { | |||
}); | |||
|
|||
const currentZipcodeValue = watch('zipcode'); | |||
const shouldShowCountyInput = zipcodeSchema.safeParse(currentZipcodeValue).success; | |||
const parsedZipCode = zipcodeSchema.safeParse(currentZipcodeValue); |
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.
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.
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 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], |
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.
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.
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.
The new way, removes the spaces, so that we don't get a key error.
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.
Please see the comments regarding some of the refactored Zipcode
variables and expressions.
What (if any) features are you implementing?
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.