mirror of
https://github.com/NativeScript/NativeScript.git
synced 2025-11-05 13:26:48 +08:00
Fix: ListPicker selected index coercing
This commit is contained in:
@@ -46,7 +46,6 @@ export const itemsProperty = new Property<ListPickerBase, any[] | ItemsSource>({
|
||||
name: "items", valueChanged: (target, oldValue, newValue) => {
|
||||
let getItem = newValue && (<ItemsSource>newValue).getItem;
|
||||
target.isItemsSource = typeof getItem === "function";
|
||||
selectedIndexProperty.coerce(target);
|
||||
}
|
||||
});
|
||||
itemsProperty.register(ListPickerBase);
|
||||
|
||||
@@ -137,6 +137,9 @@ export class ListPicker extends ListPickerBase {
|
||||
let maxValue = value && value.length > 0 ? value.length - 1 : 0;
|
||||
this.android.setMaxValue(maxValue);
|
||||
this._fixNumberPickerRendering();
|
||||
|
||||
// Coerce selected index after we have set items to native view.
|
||||
selectedIndexProperty.coerce(this);
|
||||
}
|
||||
|
||||
get [colorProperty.native](): { wheelColor: number, textColor: number } {
|
||||
|
||||
@@ -46,6 +46,9 @@ export class ListPicker extends ListPickerBase {
|
||||
}
|
||||
set [itemsProperty.native](value: any[] | ItemsSource) {
|
||||
this.ios.reloadAllComponents();
|
||||
|
||||
// Coerce selected index after we have set items to native view.
|
||||
selectedIndexProperty.coerce(this);
|
||||
}
|
||||
|
||||
get [backgroundColorProperty.native](): UIColor {
|
||||
|
||||
Reference in New Issue
Block a user