-
Notifications
You must be signed in to change notification settings - Fork 3
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
Validate forms on submit, restyle validation messages #82
base: master
Are you sure you want to change the base?
Conversation
@@ -85,7 +85,9 @@ export const AddTestToIdentifierPage: FC = () => { | |||
}); | |||
|
|||
const fieldError = (key: keyof FormFields) => | |||
form.touched[key] && form.errors[key] ? <Text>{form.errors[key]}</Text> : null; | |||
(form.submitCount > 0 || form.touched[key]) && form.errors[key] ? ( |
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.
Seen this logic three times now, maybe you should move to a library?
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.
Yup, will see if I can create a type-safe component 👍
@@ -13,7 +13,11 @@ interface TestFieldsProps { | |||
|
|||
export const TestFields: FC<TestFieldsProps> = ({ form, testType }) => { | |||
const fieldError = (key: keyof TestType['resultsSchema']['properties']) => | |||
form.touched[key] && form.errors[key] ? <Text>{form.errors[key]}</Text> : null; | |||
(form.submitCount > 0 || form.touched[key]) && form.errors[key] ? ( |
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.
4 :-)
@@ -99,5 +99,6 @@ | |||
"addTestToIdentifierPage.form.identifier.invalid.magicLink": "Please check the email address", | |||
"addTestToIdentifierPage.form.identifier.invalid.estonianId": "Please check the identification code", | |||
"addTestToIdentifierPage.button": "Add test result", | |||
"addTestToIdentifierPage.success": "Test result for {{ identifier }} added." | |||
"addTestToIdentifierPage.success": "Test result for {{ identifier }} added.", | |||
"testFields.error.generic": "Please check the input" |
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.
Slightly odd phrase. Perhaps something more like "Invalid value, please try again"?
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.
Agreed, tried to follow the Please x phrasing of the other messages, but it ended up weird.
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 fine other than those small things
Context
The current form experience is not great, as the immediate validation messages make the rest of the form jump. In addition, the form validation messages have the body text colour and are not noticeable.
Changes
Screenshots
After
Before
(schema errors)