Skip to content
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

Move transferProps back from fieldset to input in RadioField (#481) #502

Merged
merged 1 commit into from
Oct 18, 2023
Merged
Show file tree
Hide file tree
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
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