File tree Expand file tree Collapse file tree 5 files changed +26
-3
lines changed
src-docs/src/views/form_validation Expand file tree Collapse file tree 5 files changed +26
-3
lines changed Original file line number Diff line number Diff line change 2929## [ ` 25.0.0 ` ] ( https://github.com/elastic/eui/tree/v25.0.0 )
3030
3131- Added conditional rendering of the title element in ` EuiCallOut ` to avoid usage of additional space caused by the rendered ` <div> ` element ([ #3549 ] ( https://github.com/elastic/eui/pull/3549 ) )
32+ - Added ` invalidCallout ` prop to ` EuiForm ` to allow conditional rendering of error callout([ #3585 ] ( https://github.com/elastic/eui/pull/3585 ) )
3233
3334** Bug fixes**
3435
Original file line number Diff line number Diff line change @@ -26,7 +26,9 @@ export const FormValidationExample = {
2626 Validation is achieved by applying < EuiCode > isInvalid</ EuiCode > and
2727 optionally error props onto the < strong > EuiForm</ strong > or{ ' ' }
2828 < strong > EuiFormRow</ strong > components. Errors are optional and are
29- passed as an array in case you need to list many errors.
29+ passed as an array in case you need to list more than one. You can
30+ also hide the callout by passing
31+ < EuiCode > invalidCallout=“none“</ EuiCode >
3032 </ p >
3133 ) ,
3234 source : [
Original file line number Diff line number Diff line change @@ -15,3 +15,11 @@ exports[`EuiForm renders a form element 1`] = `
1515 data-test-subj = " test subject string"
1616/>
1717` ;
18+
19+ exports [` EuiForm renders without error callout when invalidCallout is "none" 1` ] = `
20+ <div
21+ aria-label = " aria-label"
22+ class = " euiForm testClass1 testClass2"
23+ data-test-subj = " test subject string"
24+ />
25+ ` ;
Original file line number Diff line number Diff line change @@ -33,6 +33,13 @@ describe('EuiForm', () => {
3333 test ( 'renders a form element' , ( ) => {
3434 const component = render ( < EuiForm { ...requiredProps } component = "form" /> ) ;
3535
36+ expect ( component ) . toMatchSnapshot ( ) ;
37+ } ) ;
38+ test ( 'renders without error callout when invalidCallout is "none"' , ( ) => {
39+ const component = render (
40+ < EuiForm { ...requiredProps } isInvalid invalidCallout = "none" />
41+ ) ;
42+
3643 expect ( component ) . toMatchSnapshot ( ) ;
3744 } ) ;
3845} ) ;
Original file line number Diff line number Diff line change @@ -39,6 +39,10 @@ export type EuiFormProps = CommonProps &
3939 */
4040 component ?: 'form' | 'div' ;
4141 error ?: ReactNode | ReactNode [ ] ;
42+ /**
43+ * Where to display the callout with the list of errors
44+ */
45+ invalidCallout ?: 'above' | 'none' ;
4246 } ;
4347
4448export const EuiForm : FunctionComponent < EuiFormProps > = ( {
@@ -47,6 +51,7 @@ export const EuiForm: FunctionComponent<EuiFormProps> = ({
4751 isInvalid,
4852 error,
4953 component = 'div' ,
54+ invalidCallout = 'above' ,
5055 ...rest
5156} ) => {
5257 const classes = classNames ( 'euiForm' , className ) ;
@@ -68,11 +73,11 @@ export const EuiForm: FunctionComponent<EuiFormProps> = ({
6873
6974 let optionalErrorAlert ;
7075
71- if ( isInvalid ) {
76+ if ( isInvalid && invalidCallout === 'above' ) {
7277 optionalErrorAlert = (
7378 < EuiI18n
7479 token = "euiForm.addressFormErrors"
75- default = "Please address the errors in your form ." >
80+ default = "Please address the highlighted errors ." >
7681 { ( addressFormErrors : string ) => (
7782 < EuiCallOut
7883 className = "euiForm__errors"
You can’t perform that action at this time.
0 commit comments