Repository navigation
Closed
Labels
package: core@ionic/core package
Description
Bug Report
Ionic:
ionic (Ionic CLI) : 4.1.2 (/usr/local/lib/node_modules/ionic)
Ionic Framework : @ionic/angular 4.0.0-beta.12
@angular-devkit/core : 0.7.2
@angular-devkit/schematics : 0.7.2
@angular/cli : 6.1.5
@ionic/ng-toolkit : 1.0.7
@ionic/schematics-angular : 1.0.5
Cordova:
cordova (Cordova CLI) : 8.0.0
Cordova Platforms : android 7.1.1, browser 5.0.4, ios 4.5.5
Cordova Plugins : cordova-plugin-ionic-keyboard 2.1.2, cordova-plugin-ionic-webview 2.0.2, (and 7 other plugins)
System:
Android SDK Tools : 26.1.1 (/Users/chrisc/Library/Android/sdk)
ios-deploy : 2.0.0
ios-sim : 7.0.0
NodeJS : v8.11.3 (/usr/local/bin/node)
npm : 6.4.1
OS : macOS High Sierra
Xcode : Xcode 10.0 Build version 10A255
Describe the Bug
If an ion-select has ion-select-options (ngFor) bound to an array which is then updated async, the select options update OK but the selected value shown in the UI is not. This is because ion-select only sets this.text when this.valueChanged fires, not when the related ion-select-options children are refreshed.
Workaround:
Binding [selectedText] to the required selected value works:
<ion-select [(ngModel)]="offer.growerNumber" name="growerNumber" okText="OK" cancelText="Dismiss" placeholder="Choose..." [selectedText]="offer.growerNumber">
<ion-select-option *ngFor="let i of growerNumbers" [value]="i">{{i}}</ion-select-option>
</ion-select>
Expected Behavior
When data source for ion-select-option list resolves via async call, the selected value should be shown in the UI.
Additional Context
https://forum.ionicframework.com/t/ionic-4-ion-select-and-change-detection/141643/2
Reacted by Marco Turi and Elian Cordoba
Metadata
Metadata
Assignees
Labels
package: core@ionic/core package
Type
Fields
No fields configured for issues without a type.
Activity
paulstelzer commentedon Dec 7, 2018
Thanks for your issue! Could you please check if this is still an issue in
beta.17? That would be very nice :)denisroldan commentedon Dec 11, 2018
@paulstelzer Experiencing the same issue here. The values doesn't appear until you tap on them and they magically appear.
denisroldan commentedon Dec 14, 2018
@paulstelzer It magically works now. Sorry! 😅 From my side, it just works as expected on Ionic 4 latest ;)
paulstelzer commentedon Dec 14, 2018
@webprofusion-chrisc Could you check if your issue is also solved when updating to beta.18?
2 remaining items
webprofusion-chrisc commentedon Dec 15, 2018
Note as an aside that I started the test case using
ionic start myApp tabs --type=angularwhich serves up a version that's 2 releases old and has broken tabs once you upgrade, so this is a new one hosted in the sidemenu template on beta 19.Really the test here is populating the list in an async way (as you would if loading from a service), then setting the bound selected value.
The displayed selected value only becomes 'three' after you start interacting with the list, which is possibly an angular change detection thing, however the 'status' text (also updated async) displays immediately.
sneko commentedon Jan 17, 2019
I think I have the exact same issue. I use something like:
But the selectedText I can see when the select is closed is equal to
element.id + ' ' + element.nameinstead of justselectedElement.idIs it still an issue on your side?
Note that it was working with an old Angular+Ionic2 project
Note2: the syntax is due to Vue.js ;)
EDIT: I tried to fix a value without binding it to JS code with
selectedText="justATest"but it doesn't override the preview in the selectnomanshahsyed commentedon Jun 26, 2019
Hi, has anyone found the solution to this problem? I have the exact same problem. I have different pages and they share a same array. When some of the page POPs or SPLICEs an entry then the select options are not updated in the UI. Although they seem to be changed in the console.
Another tricky thing is that the select options are updated on one page but not on the other one. The difference in these pages is that the one where teh options are not updated, the ion-select is wrapped around a DIV.
fix(all): component reusage (#18963)
fix(all): component reusage (#18963)
fix(all): component reusage (#18963)
liamdebeasi commentedon Sep 4, 2019
A fix for this is available in Ionic 4.9.0. For any new bugs, please create a new issue.
Thanks!
ionitron-bot commentedon Oct 4, 2019
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.