Skip to content

Commit ef7d915

Browse files
author
vakrilov
committed
Fix: ListPicker selected index coercing
1 parent 8e6b510 commit ef7d915

File tree

3 files changed

+6
-1
lines changed

3 files changed

+6
-1
lines changed

tns-core-modules/ui/list-picker/list-picker-common.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,6 @@ export const itemsProperty = new Property<ListPickerBase, any[] | ItemsSource>({
4646
name: "items", valueChanged: (target, oldValue, newValue) => {
4747
let getItem = newValue && (<ItemsSource>newValue).getItem;
4848
target.isItemsSource = typeof getItem === "function";
49-
selectedIndexProperty.coerce(target);
5049
}
5150
});
5251
itemsProperty.register(ListPickerBase);

tns-core-modules/ui/list-picker/list-picker.android.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,9 @@ export class ListPicker extends ListPickerBase {
137137
let maxValue = value && value.length > 0 ? value.length - 1 : 0;
138138
this.android.setMaxValue(maxValue);
139139
this._fixNumberPickerRendering();
140+
141+
// Coerce selected index after we have set items to native view.
142+
selectedIndexProperty.coerce(this);
140143
}
141144

142145
get [colorProperty.native](): { wheelColor: number, textColor: number } {

tns-core-modules/ui/list-picker/list-picker.ios.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,9 @@ export class ListPicker extends ListPickerBase {
4646
}
4747
set [itemsProperty.native](value: any[] | ItemsSource) {
4848
this.ios.reloadAllComponents();
49+
50+
// Coerce selected index after we have set items to native view.
51+
selectedIndexProperty.coerce(this);
4952
}
5053

5154
get [backgroundColorProperty.native](): UIColor {

0 commit comments

Comments
 (0)