Skip to content

Commit 1fc0b8b

Browse files
authored
Merge pull request #2428 from JohnDuprey/dev
Fix form click issues
2 parents 5891171 + c5ecb6f commit 1fc0b8b

File tree

2 files changed

+51
-2
lines changed

2 files changed

+51
-2
lines changed

src/components/forms/RFFComponents.jsx

Lines changed: 49 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,9 @@ export const RFFCFormSwitch = ({
123123
>
124124
<div className={className}>
125125
<CFormSwitch
126-
{...input}
126+
onChange={input.onChange}
127+
checked={input.checked}
128+
value={input.value}
127129
// @todo revisit this, only shows green when checked
128130
valid={!meta.error && meta.touched && validate}
129131
invalid={meta.error && meta.touched && validate}
@@ -265,7 +267,9 @@ export const RFFCFormRadio = ({
265267
{({ meta, input }) => (
266268
<div className={className}>
267269
<CFormCheck
268-
{...input}
270+
onChange={input.onChange}
271+
checked={input.checked}
272+
value={input.value}
269273
valid={!meta.error && meta.touched}
270274
invalid={meta.error && meta.touched}
271275
disabled={disabled}
@@ -285,6 +289,49 @@ RFFCFormRadio.propTypes = {
285289
...sharedPropTypes,
286290
}
287291

292+
export const RFFCFormRadioList = ({
293+
name,
294+
options,
295+
className = 'mb-3',
296+
disabled = false,
297+
onClick,
298+
inline = false,
299+
}) => {
300+
return (
301+
<>
302+
<div className={className}>
303+
{options?.map((option, key) => {
304+
return (
305+
<Field name={name} type="radio" value={option.value} key={key}>
306+
{({ input }) => {
307+
return (
308+
<>
309+
<CFormCheck
310+
name={input.name}
311+
checked={input.checked}
312+
onChange={input.onChange}
313+
type="radio"
314+
{...option}
315+
disabled={disabled}
316+
onClick={onClick}
317+
inline={inline}
318+
/>
319+
</>
320+
)
321+
}}
322+
</Field>
323+
)
324+
})}
325+
</div>
326+
</>
327+
)
328+
}
329+
330+
RFFCFormRadioList.propTypes = {
331+
...sharedPropTypes,
332+
inline: PropTypes.bool,
333+
}
334+
288335
export const RFFCFormTextarea = ({
289336
name,
290337
label,

src/components/forms/index.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import {
55
RFFCFormSwitch,
66
RFFCFormInput,
77
RFFCFormRadio,
8+
RFFCFormRadioList,
89
RFFCFormTextarea,
910
RFFCFormSelect,
1011
RFFSelectSearch,
@@ -18,6 +19,7 @@ export {
1819
RFFCFormSwitch,
1920
RFFCFormInput,
2021
RFFCFormRadio,
22+
RFFCFormRadioList,
2123
RFFCFormTextarea,
2224
RFFCFormSelect,
2325
RFFSelectSearch,

0 commit comments

Comments
 (0)