@@ -56,34 +56,6 @@ const QuestionMultipleCheckboxes = ({ question, useForm }) => {
5656 >
5757 { question . config &&
5858 question . config . options . map ( ( option ) => {
59- const checkBoxConfig = {
60- 'data-testid' : 'question-singleCheckbox' ,
61- id : option . name ,
62- 'aria-describedby' : 'error_message_' + question . name ,
63- name : question . name ,
64- value : option . value ,
65- defaultChecked : question . defaultCheckedValues ?. find (
66- ( defaultValue ) => defaultValue === option . value
67- ) ,
68- ...register ( question . name , {
69- ...question . registerConfig ,
70- validate : {
71- minimumLen : question . registerConfig . minimumLen
72- ? ( ) =>
73- getValues ( ) [ question . name ] &&
74- getValues ( ) [ question . name ] . length >=
75- question . registerConfig . minimumLen
76- : ( ) => true ,
77- maximumLen : question . registerConfig . maximumLen
78- ? ( ) =>
79- getValues ( ) [ question . name ] &&
80- getValues ( ) [ question . name ] . length <=
81- question . registerConfig . maximumLen
82- : ( ) => true
83- }
84- } )
85- }
86-
8759 return (
8860 < div
8961 sx = { {
@@ -98,10 +70,34 @@ const QuestionMultipleCheckboxes = ({ question, useForm }) => {
9870 alignItems : 'center'
9971 } }
10072 >
101- { option . disableOthers ?
102- < Checkbox { ...checkBoxConfig } onChange = { disableOthers } /> :
103- < Checkbox { ...checkBoxConfig } />
104- }
73+ < Checkbox
74+ data-testid = "question-singleCheckbox"
75+ id = { option . name }
76+ aria-describedby = { 'error_message_' + question . name }
77+ name = { question . name }
78+ value = { option . value }
79+ defaultChecked = { question . defaultCheckedValues ?. find (
80+ ( defaultValue ) => defaultValue === option . value
81+ ) }
82+ { ...register ( question . name , {
83+ ...question . registerConfig ,
84+ onChange : option . disableOthers && disableOthers ,
85+ validate : {
86+ minimumLen : question . registerConfig . minimumLen
87+ ? ( ) =>
88+ getValues ( ) [ question . name ] &&
89+ getValues ( ) [ question . name ] . length >=
90+ question . registerConfig . minimumLen
91+ : ( ) => true ,
92+ maximumLen : question . registerConfig . maximumLen
93+ ? ( ) =>
94+ getValues ( ) [ question . name ] &&
95+ getValues ( ) [ question . name ] . length <=
96+ question . registerConfig . maximumLen
97+ : ( ) => true
98+ }
99+ } ) }
100+ />
105101 { option . src ? (
106102 < img src = { option . src } />
107103 ) : (
0 commit comments