-
-
Notifications
You must be signed in to change notification settings - Fork 407
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #574 from tudi2d/542-improve-form-validation
#542 - Show form validation to the user
- Loading branch information
Showing
7 changed files
with
107 additions
and
76 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,21 @@ | ||
import React from 'react' | ||
import { ImageInput } from '../ImageInput/ImageInput' | ||
import { IFieldProps } from './Fields' | ||
import { FieldContainer } from './elements' | ||
import { FieldContainer, ErrorMessage } from './elements' | ||
|
||
export const ImageInputField = ({ input, meta, ...rest }: IFieldProps) => ( | ||
<FieldContainer> | ||
<ImageInput | ||
{...rest} | ||
// as validation happens on blur also want to artificially trigger when values change | ||
// (no native blur event) | ||
onFilesChange={files => { | ||
input.onChange(files) | ||
input.onBlur() | ||
}} | ||
/> | ||
</FieldContainer> | ||
<> | ||
<FieldContainer invalid={meta.touched && meta.error}> | ||
<ImageInput | ||
{...rest} | ||
// as validation happens on blur also want to artificially trigger when values change | ||
// (no native blur event) | ||
onFilesChange={files => { | ||
input.onChange(files) | ||
input.onBlur() | ||
}} | ||
/> | ||
</FieldContainer> | ||
{meta.error && meta.touched && <ErrorMessage>{meta.error}</ErrorMessage>} | ||
</> | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -25,5 +25,6 @@ export const LocationSearchField = ({ | |
} | ||
input.onBlur() | ||
}} | ||
placeholder="Search for a location *" | ||
/> | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters