Skip to content

Commit

Permalink
fix(radio): persist checked state when items are updated in radio-gro…
Browse files Browse the repository at this point in the history
…up (#29457)

Issue number: resolves #29442

---------

<!-- Please do not submit updates to dependencies unless it fixes an
issue. -->

<!-- Please try to limit your pull request to one type (bugfix, feature,
etc). Submit multiple pull requests if needed. -->

## What is the current behavior?
<!-- Please describe the current behavior that you are modifying. -->

The state does not stay consistent when the data used to render the
radios are updated.

## What is the new behavior?
<!-- Please describe the behavior or changes that are being added by
this PR. -->

- The state updates after the component loads, this allows the value to
be set after the radio is rendered.

## Does this introduce a breaking change?

- [ ] Yes
- [x] No

<!--
  If this introduces a breaking change:
1. Describe the impact and migration path for existing applications
below.
  2. Update the BREAKING.md file with the breaking change.
3. Add "BREAKING CHANGE: [...]" to the commit description when merging.
See
https://github.com/ionic-team/ionic-framework/blob/main/docs/CONTRIBUTING.md#footer
for more information.
-->


## Other information

<!-- Any other information that is important to this PR such as
screenshots of how the component looks before and after the change. -->

Dev build: 8.1.1-dev.11714760012.1eab947e

---------

Co-authored-by: Sean Perkins <[email protected]>
  • Loading branch information
thetaPC and sean-perkins committed May 6, 2024
1 parent a57ca8d commit 7ea14ae
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions core/src/components/radio/radio.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,18 @@ export class Radio implements ComponentInterface {
*/
@Event() ionBlur!: EventEmitter<void>;

componentDidLoad() {
/**
* The value may be `undefined` if it
* gets set before the radio is
* rendered. This ensures that the radio
* is checked if the value matches. This
* happens most often when Angular is
* rendering the radio.
*/
this.updateState();
}

/** @internal */
@Method()
async setFocus(ev: globalThis.Event) {
Expand Down

0 comments on commit 7ea14ae

Please sign in to comment.