diff --git a/src/components/ConnectedField/doc.mdx b/src/components/ConnectedField/doc.mdx
index 7a0a5196e7..d2cf8eea99 100644
--- a/src/components/ConnectedField/doc.mdx
+++ b/src/components/ConnectedField/doc.mdx
@@ -217,6 +217,7 @@ You can find additional props for each field component in [Fields](/fields/file-
/>
}
name="partyDate"
component={DateTimePicker}
label="Party date"
diff --git a/src/components/Field/doc.mdx b/src/components/Field/doc.mdx
index 577fc87d48..240c01d7b6 100644
--- a/src/components/Field/doc.mdx
+++ b/src/components/Field/doc.mdx
@@ -343,7 +343,7 @@ You can find additional props for each field component in [Fields](/fields/file-
{
+ if (isCheckable) return
const input = inputRef.current
if (input) {
- switch (Component.displayName) {
- case 'InputRadio':
- case 'RadioTab':
- case 'Checkbox':
- break
- case 'MarkdownEditor':
- input.simpleMde.codemirror.focus()
- break
- default:
- input.focus()
- }
+ Component.displayName === 'MarkdownEditor'
+ ? input.simpleMde.codemirror.focus()
+ : input.focus()
}
}
+ const handleChecked = () => (baseType === 'checkbox' ? isCheckboxChecked : checked)
+
const field = (
(
-
- )
+ (
+ { checked, Component = S.InputCheckbox, name, onChange, order, setIsCheckboxChecked, ...rest },
+ ref
+ ) => {
+ const toggle = () => setIsCheckboxChecked(!checked)
+ const handleChange = e => onChange && onChange(e)
+
+ return (
+
+ )
+ }
)
InputCheckbox.type = 'InputCheckbox'
diff --git a/src/components/InputRadio/index.js b/src/components/InputRadio/index.js
index ea564efd4d..c6df249a4e 100644
--- a/src/components/InputRadio/index.js
+++ b/src/components/InputRadio/index.js
@@ -1,12 +1,11 @@
import React, { forwardRef } from 'react'
-import { bool, elementType, func, number, string } from 'prop-types'
-import { useRadioState } from 'reakit/Radio'
+import { bool, elementType, func, number, object, string } from 'prop-types'
import * as S from './styles'
-export const InputRadio = forwardRef(({ name, order, value, ...rest }, ref) => {
- const radio = useRadioState()
- return (
+export const InputRadio = forwardRef(
+ ({ name, order, radio, setIsCheckboxChecked, value, ...rest }, ref) => (
+ // setIsCheckboxChecked is here to remove it from the DOM element
{
{...radio}
/>
)
-})
+)
InputRadio.type = 'InputRadio'
InputRadio.displayName = 'InputRadio'
@@ -33,6 +32,8 @@ InputRadio.propTypes = {
onFocus: func,
onKeyDown: func,
order: number,
+ radio: object,
+ setIsCheckboxChecked: func,
type: string,
value: string
}
diff --git a/src/components/RadioGroup/index.js b/src/components/RadioGroup/index.js
index 50345430d2..b02b46a99d 100644
--- a/src/components/RadioGroup/index.js
+++ b/src/components/RadioGroup/index.js
@@ -1,18 +1,25 @@
import React, { cloneElement } from 'react'
import { bool, node, string } from 'prop-types'
+import { RadioGroup as ReakitRadioGroup, useRadioState } from 'reakit/Radio'
import { DIRECTIONS_TYPE } from '../../utils'
import { FieldGroup } from '../FieldGroup'
import * as S from './styles'
-export const RadioGroup = ({ children, flexDirection, label, required }) => (
-
-
- {children.map(child => cloneElement(child, { key: child.props.value, flexDirection }))}
-
-
-)
+export const RadioGroup = ({ children, flexDirection, label, required }) => {
+ const radio = useRadioState()
+
+ return (
+
+
+ {children.map(child =>
+ cloneElement(child, { key: child.props.value, flexDirection, radio: { ...radio } })
+ )}
+
+
+ )
+}
RadioGroup.propTypes = {
children: node,