File tree Expand file tree Collapse file tree 3 files changed +15
-6
lines changed
Expand file tree Collapse file tree 3 files changed +15
-6
lines changed Original file line number Diff line number Diff line change 11import React , { HTMLProps } from 'react' ;
2- import classNames from 'classnames' ;
32import FormContext from './FormContext' ;
43
54type FormProps = HTMLProps < HTMLFormElement > & {
65 disableErrorFromComponents ?: boolean ;
76} ;
87
9- const Form : React . FC < FormProps > = ( { className , disableErrorFromComponents, ...rest } ) => (
8+ const Form : React . FC < FormProps > = ( { disableErrorFromComponents, ...rest } ) => (
109 < FormContext . Provider value = { { disableErrorFromComponents : Boolean ( disableErrorFromComponents ) } } >
11- < form className = { classNames ( 'nhsuk-form-group--wrapper' , className ) } { ...rest } />
10+ < form { ...rest } />
1211 </ FormContext . Provider >
1312) ;
1413
Original file line number Diff line number Diff line change @@ -43,6 +43,7 @@ const FormGroup = <T extends BaseFormElementRenderProps>(props: FormGroupProps<T
4343 error,
4444 hintProps,
4545 errorProps,
46+ formGroupProps,
4647 inputType,
4748 disableErrorLine,
4849 name,
@@ -79,11 +80,18 @@ const FormGroup = <T extends BaseFormElementRenderProps>(props: FormGroupProps<T
7980 return ( ) => registerComponent ( elementID , true ) ;
8081 } , [ ] ) ;
8182
83+ const { className : formGroupClassName , ...formGroupRestProps } = formGroupProps || { } ;
84+
8285 return (
8386 < div
84- className = { classNames ( 'nhsuk-form-group' , {
85- 'nhsuk-form-group--error' : ! disableErrorFromComponents && ! disableErrorLine && error ,
86- } ) }
87+ className = { classNames (
88+ 'nhsuk-form-group' ,
89+ {
90+ 'nhsuk-form-group--error' : ! disableErrorFromComponents && ! disableErrorLine && error ,
91+ } ,
92+ formGroupClassName ,
93+ ) }
94+ { ...formGroupRestProps }
8795 >
8896 { label ? (
8997 < Label id = { labelID } htmlFor = { elementID } { ...labelProps } >
Original file line number Diff line number Diff line change 1+ import { HTMLProps } from 'react' ;
12import { ErrorMessageProps } from '../../components/error-message/ErrorMessage' ;
23import { HintProps } from '../../components/hint/Hint' ;
34import { LabelProps } from '../../components/label/Label' ;
@@ -9,6 +10,7 @@ export interface FormElementProps {
910 errorProps ?: ErrorMessageProps ;
1011 hint ?: string ;
1112 hintProps ?: HintProps ;
13+ formGroupProps ?: HTMLProps < HTMLDivElement > ;
1214 disableErrorLine ?: boolean ;
1315 id ?: string ;
1416 name ?: string ;
You can’t perform that action at this time.
0 commit comments