Skip to content

fix radio/checkbox bug #2270

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Mar 27, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 15 additions & 2 deletions src/components/forms/RFFComponents.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import Select from 'react-select'
import Creatable, { useCreatable } from 'react-select/creatable'
import { Field } from 'react-final-form'
import { FieldArray } from 'react-final-form-arrays'
import React, { useState, useMemo, useRef } from 'react'
import React, { useState, useMemo } from 'react'
import PropTypes from 'prop-types'
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'
import { debounce } from 'lodash-es'
Expand All @@ -37,6 +37,7 @@ const sharedPropTypes = {
error: PropTypes.any,
}),
}),
onClick: PropTypes.func,
}

export const RFFCFormFeedback = ({ meta }) => {
Expand All @@ -54,7 +55,14 @@ RFFCFormFeedback.propTypes = {
}),
}

export const RFFCFormCheck = ({ name, label, className = 'mb-3', validate, disabled = false }) => {
export const RFFCFormCheck = ({
name,
label,
className = 'mb-3',
validate,
disabled = false,
onClick,
}) => {
return (
<Field name={name} type="checkbox" validate={validate}>
{({ input, meta }) => (
Expand All @@ -67,6 +75,7 @@ export const RFFCFormCheck = ({ name, label, className = 'mb-3', validate, disab
disabled={disabled}
id={name}
label={label}
onClick={onClick}
/>
<RFFCFormFeedback meta={meta} />
</div>
Expand All @@ -92,6 +101,7 @@ export const RFFCFormSwitch = ({
validate,
disabled = false,
initialValue,
onClick,
}) => {
return (
<Field initialValue={initialValue} name={name} type="checkbox" validate={validate}>
Expand All @@ -113,6 +123,7 @@ export const RFFCFormSwitch = ({
disabled={disabled}
id={name}
label={label}
onClick={onClick}
/>
{input.value && <RFFCFormFeedback meta={meta} />}
<sub>{sublabel}</sub>
Expand Down Expand Up @@ -239,6 +250,7 @@ export const RFFCFormRadio = ({
className = 'mb-3',
validate,
disabled = false,
onClick,
}) => {
return (
<Field name={name} type="radio" value={value} validate={validate}>
Expand All @@ -252,6 +264,7 @@ export const RFFCFormRadio = ({
type="radio"
name={name}
label={label}
onClick={onClick}
/>
<RFFCFormFeedback meta={meta} />
</div>
Expand Down