Skip to content

Commit

Permalink
Merge pull request #337 from oasisrising/issue-336
Browse files Browse the repository at this point in the history
fix: make checkbox groups accessible via fieldset & legend (issue #336)
  • Loading branch information
dohomi authored Jan 6, 2025
2 parents 1b256b2 + 70fb46b commit 9757ea7
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 6 deletions.
17 changes: 14 additions & 3 deletions packages/rhf-mui/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,26 @@
"license": "MIT",
"repository": "https://github.com/dohomi/react-hook-form-mui",
"homepage": "https://react-hook-form-material-ui.vercel.app",
"keywords": ["react", "mui", "material-ui", "react-hook-form"],
"workspaces": ["apps/*", "packages/*"],
"keywords": [
"react",
"mui",
"material-ui",
"react-hook-form"
],
"workspaces": [
"apps/*",
"packages/*"
],
"name": "react-hook-form-mui",
"author": "Dominic Garms",
"source": "src/index.ts",
"main": "dist/index.js",
"module": "dist/esm/index.js",
"typings": "dist/index.d.ts",
"files": ["dist/**", "src/**"],
"files": [
"dist/**",
"src/**"
],
"exports": {
"./package.json": "./package.json",
".": {
Expand Down
11 changes: 8 additions & 3 deletions packages/rhf-mui/src/CheckboxButtonGroup.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ const CheckboxButtonGroup = forwardRef(function CheckboxButtonGroup<
TValue = unknown,
>(
props: CheckboxButtonGroupProps<TFieldValues, TName, TValue>,
ref: Ref<HTMLDivElement>
ref: Ref<HTMLFieldSetElement>
) {
const {
helperText,
Expand Down Expand Up @@ -155,8 +155,13 @@ const CheckboxButtonGroup = forwardRef(function CheckboxButtonGroup<
: helperText

return (
<FormControl error={invalid} required={required} ref={ref}>
{label ? <FormLabel>{label}</FormLabel> : null}
<FormControl
error={invalid}
required={required}
ref={ref}
component="fieldset"
>
{label ? <FormLabel component="legend">{label}</FormLabel> : null}
<FormGroup row={row}>
{options.map((option) => {
const optionValue = propertyExists(option, valueKey)
Expand Down

0 comments on commit 9757ea7

Please sign in to comment.