Skip to content

bug: radio button disabled prop doesn't handle undefined #28677

Description

@nmspackman

Prerequisites

Ionic Framework Version

v7.x

Current Behavior

An IonRadio component with undefined passed as a value to the disabled prop causes the radio to not trigger the onIonChange function when selected. The visual effect is the previous selection and the current selection (with disabled set to undefined) will both be selected.'

Note: Cherries is the radio that has disabled set to undefined.
image

Expected Behavior

The radio button should be selected and the radio group value should update.

Steps to Reproduce

  1. Create an IonRadioGroup with 3 IonRadio components nested (values are arbitrary)
  2. Set one of the IonRadio's disabled prop to undefined
  3. When viewing the UI, click one of the radios without the disabled prop set, then click the radio with it set

Code Reproduction URL

https://stackblitz.com/edit/f4avhg?file=src%2Fmain.tsx

Ionic Info

N/A

Additional Information

To work around this issue, I set the disabled prop using strict equals for comparing the variable passed in. It looks something like this:

<IonRadio value="cherries" disabled={options?.isDisabled === true}>
    Cherries
</IonRadio>

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions