Skip to content

fix: 3.7_Radio_isuue#1413

Open
deepakoram-juspay wants to merge 1 commit into
devfrom
fix/3.7_Radio_issue
Open

fix: 3.7_Radio_isuue#1413
deepakoram-juspay wants to merge 1 commit into
devfrom
fix/3.7_Radio_issue

Conversation

@deepakoram-juspay
Copy link
Copy Markdown
Collaborator

@deepakoram-juspay deepakoram-juspay commented May 18, 2026

Summary

styled.input contains an input of type radio with both checked and defaultChecked props. Input elements must be either controlled or uncontrolled

Issue Ticket

Closes #1443

@deepakoram-juspay deepakoram-juspay self-assigned this May 18, 2026
@pkg-pr-new
Copy link
Copy Markdown

pkg-pr-new Bot commented May 18, 2026

Open in StackBlitz

npm i https://pkg.pr.new/@juspay/blend-design-system@1413

commit: 9e874ac

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Fixes the Radio component to avoid passing both checked and defaultChecked to the underlying <input type="radio">, eliminating React’s controlled/uncontrolled warning and aligning styling with the native :checked state.

Changes:

  • Updated Radio to conditionally pass either checked (controlled) or defaultChecked (uncontrolled), and added readOnly for controlled-without-onChange cases to avoid React warnings.
  • Refactored StyledRadioInput to use CSS :checked selectors instead of a custom $isChecked prop.
  • Added an accessibility test to ensure no console error occurs when both props are provided to Radio (with checked taking precedence).

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.

File Description
packages/blend/lib/components/Radio/StyledRadio.tsx Removes $isChecked and switches styling to native :checked state.
packages/blend/lib/components/Radio/Radio.tsx Ensures input is either controlled or uncontrolled by conditionally spreading checked vs defaultChecked.
packages/blend/tests/components/Radio/Radio.accessibility.test.tsx Adds coverage to guard against the React warning about mixing checked and defaultChecked.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +273 to +291
render(
<Radio
value="controlled"
checked={false}
defaultChecked
onChange={() => {}}
>
Controlled radio
</Radio>
)

const radio = screen.getByRole('radio', {
name: 'Controlled radio',
})

expect(radio).not.toBeChecked()
expect(consoleError).not.toHaveBeenCalled()

consoleError.mockRestore()
Comment on lines 7 to 12
export const StyledRadioInput = styled.input<{
size: RadioSize
$isDisabled: boolean
$isChecked: boolean
$error?: boolean
$tokens: RadioTokensType
}>`
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Radio : both checked and defaultChecked on the same <input type="radio">

2 participants