From ad7ce790f4fae907bf2b0f64fa492b18e79a23a0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Ribeiro?= Date: Fri, 3 May 2024 23:54:28 -0300 Subject: [PATCH] fix(RadioGroup): make it easier to select options closes CLICK-801 --- .eslintrc.js | 2 ++ .../FormBuilder/fields/RadioGroupField.tsx | 35 ++++++++++--------- src/components/ui/Form.tsx | 24 +++++++------ src/components/ui/RadioGroup.tsx | 27 +++++++++++++- 4 files changed, 61 insertions(+), 27 deletions(-) diff --git a/.eslintrc.js b/.eslintrc.js index 88a409a..b376a9e 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -39,6 +39,8 @@ module.exports = { "react/jsx-filename-extension": "off", "react/jsx-props-no-spreading": "off", "react/require-default-props": "off", + "react/react-in-jsx-scope": "off", + "react/jsx-uses-react": "off", "typescript-sort-keys/interface": "error", "typescript-sort-keys/string-enum": "error", "unused-imports/no-unused-imports": "error", diff --git a/src/components/FormBuilder/fields/RadioGroupField.tsx b/src/components/FormBuilder/fields/RadioGroupField.tsx index 39e0789..6c1e72c 100644 --- a/src/components/FormBuilder/fields/RadioGroupField.tsx +++ b/src/components/FormBuilder/fields/RadioGroupField.tsx @@ -1,4 +1,3 @@ -import React from "react"; import { cva } from "class-variance-authority"; import { cn } from "#/lib/utils"; import { @@ -10,7 +9,11 @@ import { FormMessage, } from "#/components/ui/Form"; import { Label } from "#/components/ui/Label"; -import { RadioGroup, RadioGroupItem } from "#/components/ui/RadioGroup"; +import { + RadioGroup, + RadioGroupItem, + RadioGroupItemWithChildren, +} from "#/components/ui/RadioGroup"; import { BaseField, withConditional } from "../fields"; export interface RadioGroupFieldProps extends BaseField { @@ -55,25 +58,25 @@ const RadioGroupWithoutSection = ({ form, field }) => ( - {field.options.map((option) => ( + {field.options.map((option, idx) => ( 1, + })} > - { - rcfField.onChange( - rcfField.value === option.value ? null : option.value - ); - }} - > - + + + + {option.label} + + - - {option.label} - ))} diff --git a/src/components/ui/Form.tsx b/src/components/ui/Form.tsx index 7b3e539..03e22bd 100644 --- a/src/components/ui/Form.tsx +++ b/src/components/ui/Form.tsx @@ -215,18 +215,22 @@ const FormLabel = React.forwardRef< >(({ className, tooltip, ...props }, ref) => { const { error, formItemId } = useFormField(); - return ( - -
-