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

bug: ion-radio does not keep checked-state after updating the underlaying object #29442

Closed
3 tasks done
mariusbolik opened this issue May 2, 2024 · 3 comments · Fixed by #29457
Closed
3 tasks done
Labels
package: core @ionic/core package type: bug a confirmed bug report

Comments

@mariusbolik
Copy link

Prerequisites

Ionic Framework Version

v8.x

Current Behavior

Initially, the ion-radio-button is checked correctly. But after updating the objects that contain the data that is used to display the ion-radion-buttons, the checked-state gets lost, even though the value property stays the same. Seems that this bug appears on Angular standalone projects.

Perhaps this error could be related to the following issue: #29414
It could also be that this error can be found in other components, such as ion-accordion.

Expected Behavior

The active ion-radio-button should be highlighted when it's value matches the value of it's containing ion-radio-group - as was the case before standalone components.

Steps to Reproduce

  1. Go to https://stackblitz.com/edit/angular-vquurr-ec7ark?file=src%2Fapp%2Fexample.component.html
  2. Click the "Update Data" Button

Code Reproduction URL

https://stackblitz.com/edit/angular-vquurr-ec7ark?file=src%2Fapp%2Fexample.component.html

Ionic Info

Ionic CLI : 7.2.0
Ionic Framework : @ionic/angular 8.0.1
@angular-devkit/build-angular : 17.3.6
@angular-devkit/schematics : 17.3.6
@angular/cli : 17.3.6
@ionic/angular-toolkit : 11.0.1

Additional Information

No response

@mariusbolik
Copy link
Author

Same for ion-accordion: https://stackblitz.com/edit/angular-vquurr-6urqjk?file=src%2Fapp%2Fexample.component.html
And maybe ion-checkbox, ion-toggle, ion-menu are also affected. Can someone from the Ionic Team whith deeper understanding in code architecture investigate if this bug applies to more components?

@thetaPC
Copy link
Contributor

thetaPC commented May 3, 2024

Thank you for the issue!

I was able to replicate it and wrote up a fix for it. Feel free to test out the dev build:

npm install @ionic/[email protected]

@thetaPC thetaPC added package: core @ionic/core package type: bug a confirmed bug report labels May 3, 2024
@ionitron-bot ionitron-bot bot removed the triage label May 3, 2024
@thetaPC thetaPC removed their assignment May 3, 2024
github-merge-queue bot pushed a commit that referenced this issue May 6, 2024
…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]>
@thetaPC
Copy link
Contributor

thetaPC commented May 6, 2024

Thanks for the issue! This has been resolved via PR #29457 and will be available in an upcoming release of Ionic.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
package: core @ionic/core package type: bug a confirmed bug report
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants