Skip to content

Commit

Permalink
Move transferProps back from fieldset to input in RadioField (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
bedrich-schindler authored and adamkudrna committed Oct 18, 2023
1 parent 5ca5a06 commit bc1744f
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 7 deletions.
4 changes: 2 additions & 2 deletions src/components/Radio/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -281,8 +281,8 @@ It's possible to disable just some options or the whole set.
In addition to the options below in the [component's API](#api) section, you
can specify [React synthetic events] or you can **add whatever HTML attribute
you like.** All attributes that don't interfere with the API are forwarded to
the native HTML `<input>`. This enables making the component interactive and helps
to improve its accessibility.
the native HTML `<input>` elements. This enables making the component
interactive and helps to improve its accessibility.

👉 Refer to the MDN reference for the full list of supported attributes of the
[radio] input type.
Expand Down
6 changes: 1 addition & 5 deletions src/components/Radio/Radio.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ export const Radio = ({

return (
<fieldset
{...transferProps(restProps)}
className={classNames(
styles.root,
context && styles.isRootInFormLayout,
Expand Down Expand Up @@ -68,17 +67,14 @@ export const Radio = ({
key={key}
>
<input
{...transferProps(restProps)}
checked={restProps.onChange
? (value === option.value) || false
: undefined}
className={styles.input}
disabled={disabled || option.disabled}
id={id && `${id}__item__${key}`}
name={id}
// The change is handled by the `<fieldset>` element. This is a placeholder to prevent React from
// showing the warning about uncontrolled input: "You provided a `checked` prop to a form field
// without an `onChange` handler."
onChange={() => {}}
type="radio"
value={option.value}
/>
Expand Down

0 comments on commit bc1744f

Please sign in to comment.