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

feat(radio): add typescript support for accepting react node #200

Merged
merged 2 commits into from
Mar 27, 2024
Merged
Changes from 1 commit
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/radio/Radio.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ export type RadioProps = {
/**
* The actual text to be displayed `Cats For Adoptions`
*/
label: string;
label: string | ReactNode;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm okay with this but note that this has a bit of a11y implications. Can you double check that the text node of whatever react node you pass in get's read in for a11y?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Verified with Chrome Lighthouse that there were no accessibility issues using a node. From the code, it looks like all aria values are appended using the value prop being passed in, so the label being a node should not affect (unless the node being passed in does not pass a11y)

/**
* Additional functionality after the select
*/
Expand Down Expand Up @@ -104,7 +104,7 @@ function Radio(props: RadioProps) {
};

const radioChildren = children
? React.Children.map(props.children, (child) =>
? React.Children.map(props.children, child =>
isValidElement(child)
? React.cloneElement(child as ReactElement<any>, { isDisabled })
: child
Expand Down
Loading