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

fix(radio-group): emit value change on componentDidLoad #28488

Merged
merged 2 commits into from Nov 10, 2023
Merged

fix(radio-group): emit value change on componentDidLoad #28488

merged 2 commits into from Nov 10, 2023

Conversation

thetaPC
Copy link
Contributor

@thetaPC thetaPC commented Nov 8, 2023

Issue number: resolves #28356


What is the current behavior?

ion-radio-group would not set the radio value when using it as a Angular standalone component and data binding:

<ion-radio-group [value]="fromValue">
  <ion-radio value="dogs">Dogs</ion-radio><br />
  <ion-radio value="cats">Cats</ion-radio><br />
  <ion-radio value="turtles">Turtles</ion-radio><br />
  <ion-radio value="fish">Fish</ion-radio><br />
</ion-radio-group>

This is happening because the value is set before the value watcher has been configured. The event, ionValueChange, does not get dispatched.

What is the new behavior?

Run valueChanged() in componentDidLoad().

Does this introduce a breaking change?

  • Yes
  • No

Other information

In our testing, we observed that the issue described below only occurs when assigning a value to the radio group within the primary content, such as rendering within the app component template.

When the template is isolated to a route, the value is assigned correctly. To address this issue, we need to ensure that the watcher is called after the component has finished loading, allowing the emit to be dispatched correctly.

Dev build: 7.5.4-dev.11699404450.136700d7

@github-actions github-actions bot added the package: core @ionic/core package label Nov 8, 2023
@thetaPC thetaPC marked this pull request as ready for review November 8, 2023 21:23
@sean-perkins

This comment was marked as outdated.

@medbenmakhlouf
Copy link
Contributor

I think the same problem is happening with <ion-accordion-group [value]="fromValue">, maybe the fix could be similar ?

@thetaPC
Copy link
Contributor Author

thetaPC commented Nov 9, 2023

I think the same problem is happening with <ion-accordion-group [value]="fromValue">, maybe the fix could be similar ?

@medbenmakhlouf Appreciate you flagging the issue! To help us manage and fix it more effectively, it would be great if you could open a new GitHub issue with a reproduction. This way, we can keep track of the problem and work towards a solution.

@medbenmakhlouf
Copy link
Contributor

@thetaPC , just did here. Thanks!

Copy link
Contributor

@sean-perkins sean-perkins left a comment

Choose a reason for hiding this comment

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

Changes look good 👍

@thetaPC thetaPC added this pull request to the merge queue Nov 10, 2023
Merged via the queue into main with commit 73b8bfd Nov 10, 2023
45 checks passed
@thetaPC thetaPC deleted the FW-5386 branch November 10, 2023 22:26
github-merge-queue bot pushed a commit that referenced this pull request Jan 17, 2024
Issue number: resolves #28816

---------

<!-- 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 value is set on Segment asynchronously when binding it in Angular.
However, the timing works out such that the value changes after
`connectedCallback` is fired but before any Stencil Watchers are
configured. As a result, our `value` property watcher does not fire
which causes `ionSelect` to not be emitted. Segment Buttons rely on this
event to know when to update their state (if the value changes such that
a segment button is now selected). This results in a checked segment
button not appearing checked.

This is similar to other issues that have been fixed:

#28510
#28488
#28526

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

- Segment now emits `ionSelect` on `componentDidLoad` so that any
descendant segment buttons can update correctly.

## 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/.github/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: `7.6.5-dev.11705415448.16878103`

This is a timing issue with Stencil, so I am unable to write a reliable
automated test. Reviewers should test the dev build in the repro
provided in the linked issue.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
package: core @ionic/core package
Projects
None yet
Development

Successfully merging this pull request may close these issues.

bug: [v7.5] ion-radio-group doesn't work with variables with standalone components
3 participants