-
Notifications
You must be signed in to change notification settings - Fork 13.5k
bug: ion-select doesn't recognize delayed or updated select options #19324
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
Comments
Thanks for the issue. Please try this again using |
Thanks for the tip. I modified the stackblitz. Using https://stackblitz.com/edit/ionic-v4-angular-tabs-ecdgvr?file=src%2Fapp%2Fhome%2Fhome.page.ts |
I'm having the exact same problem with Ionic 4.9.1. 4.7.x and 4.8.x didn't had that issue. |
Exact same issue too with Ionic 4.10.0-dev.201909261535.8ca97ce |
On 4.10.1 the issue is still there. Issue #19436 sounds similar. |
I think I found the problem. @liamdebeasi, why the functionality of the file It seems like it was the responsible of detect changes inside the DOM of Maybe I can't see by which other functionality it was replaced, please, can you help us? I hope I provided you enough information. @Listen('ionSelectOptionDidLoad')
@Listen('ionSelectOptionDidUnload')
async selectOptionChanged() {
await this.loadOptions();
if (this.didInit) {
this.updateOptions();
this.updateOverlayOptions();
this.emitStyle();
/**
* In the event that options
* are not loaded at component load
* this ensures that any value that is
* set is properly rendered once
* options have been loaded
*/
if (this.value !== undefined) {
this.el.forceUpdate();
}
}
} |
Issue #19828 looks similar. Any updates from Ionic-Team on this matter? |
Thanks for the follow up. I've marked this as a bug. The select component was updated to fix a few other bugs, but it looks like this functionality broke in the process. I will look into an appropriate fix for this and will post an update here when I have more to share. Thanks! |
@liamdebeasi Any update on this matter? |
Hi there,
As for now the only working solutions to this are
Very annoying, hopefully we see a fix soon... |
We are having the same problem with 4.11.6, demo here : https://angular-ionic-4-efei58.stackblitz.io/home Second menu value is bound correctly, and if you open the menu the value is highlighted correctly, but it doesn't display. |
Bug still exist with 5.0.x. I can confirm that adding |
This was a problem also on older versions as well, which was fixed previously and now it is back from a while. We use ngx-formly and have created a merge request to workaround this problem |
How do you deal with this issue if you're using an observable to populate the select options? I had to resort to angular-material's mat-select to get this working. |
Something like that
|
a major bug still open after half a year. actually to fix it i think it would take just a few minutes. i think this is urgent, because forms just doesn't work. most of the time values are loaded async and boom it doesn't work.
|
@nickwinger If you have an idea for how to resolve the issue, would you be interested in making a PR for it? I'd be happy to review it. |
@liamdebeasi Well i'm not into the internals of Ionic and how you do the angular wrapping since you moved to stencil, but i know that you implement the interface ControlValueAccessor in angular to be able to support formControlName. Then there are many options how to recognize if the children ion-select-options change. Vanilla DOM would be to make a MutationObserver. |
This worked for me
|
Already have faced this issue. The only workaround I've found is setting values async as well. Let' suppose I have some Then instead of setting values direclty the following trick does the job:
See stackblitz |
My extremely hacky solution was, on setting the select's values, to hide the select for a single tick and then immediately show it again. This forces the component to re-render and is practically invisible.
|
Please, please, fix it! May be it's not so good design to depend entirely on DOM elements of |
Actually what we did is to wrap ion-select in our own foo-select angular component and implemented the control value accessor on the foo-select. That way you can use foo-select for the reactive form and use *ngIf on the ion-select. It's not pretty, but it did the job for us. |
Has this been resolved? Any suggestions for Ionic 5, Angular 12? |
having the same issue on ionic/vue v 5.4.0 |
Still having that with:
|
Same issue
|
This worked for me when I put a function call in the placeholder field. |
Same issue |
Same issue
|
Same issue. One solution here was set initial value empty when creating form And then when you load data via api then set
My package versions
|
Hi everyone, I have a dev build with a proposed fix if anyone is interested in testing: Angular
React
Vue
Stencil/Vanilla JavaScript
|
Thanks for the issue. This has been resolved via #26667, and a fix will be available in an upcoming release of Ionic Framework. Please feel free to continue testing this dev build, and let me know if you have any questions. |
Thanks for the issue! This issue is being locked to prevent comments that are not relevant to the original issue. If this is still an issue with the latest version of Ionic, please create a new issue and ensure the template is fully filled out. |
Bug Report
Ionic version:
[x] 4.9.0
Current behavior:
If ion-select-options are passed with a delay, the selected property is not respected.
This happens e.g. if you get the options via http request.
Expected behavior:
The selected binding should work, with or without, the delay.
Steps to reproduce:
See stackblitz.
Related code:
https://stackblitz.com/edit/ionic-v4-angular-tabs-ecdgvr?file=src%2Fapp%2Fhome%2Fhome.page.ts
The text was updated successfully, but these errors were encountered: