Skip to content

Commit

Permalink
Merge pull request #6 from NativeScript/amiorkov/text-speed-update-fix
Browse files Browse the repository at this point in the history
Fix for "slow" text update after selection in the list
  • Loading branch information
VladimirAmiorkov authored Mar 6, 2019
2 parents e93e577 + f8fc350 commit 94ad41b
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<GridLayout rows="100, *" columns="*, *" [formGroup]="movieForm" class="yellow-grid">
<Label row="0" col="0" text="Pick a movie:" class="black-label label-center field-name-label"></Label>
<PickerField #picker row="0" col="1" formControlName="movie" hint="select a movie" padding="10" pickerTitle="Pick a movie"
class="picker-field" modalClass="myModal" valueField="year" textField="name" [items]="pickerItems">
class="picker-field" modalClass="myModal" valueField="id" textField="name" [items]="pickerItems">
<ng-template let-item="item">
<GridLayout rows="auto, *" columns="*, auto" class="yellow-grid">
<Label [text]="item.name" colSpan="2" class="black-label item-template-top-label"></Label>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ export class ReactiveFormsExampleComponent implements OnInit {
]);

this.movieForm = new FormGroup({
movie: new FormControl(this.pickerItems.getItem(0).year, Validators.required),
movie: new FormControl(this.pickerItems.getItem(0).id, Validators.required),
});
}

Expand Down
14 changes: 7 additions & 7 deletions src/picker.common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -156,20 +156,20 @@ export class PickerField extends TextField implements TemplatedItemsView {

const context = this;
const callback = (sender: View, selectedIndex: number) => {
if (selectedIndex !== undefined) {
let object = this.getDataItem(selectedIndex);
this.selectedIndex = selectedIndex;

this._updateSelectedValue(object);
}

this.disposeModalView();
};
this._modalRoot.navigate(() => this._page);
this.showModal(this._modalRoot, context, callback, true, this.modalAnimated);
}

private listViewItemTapHandler(args: ItemEventData) {
if (args.index !== undefined) {
let object = this.getDataItem(args.index);
this.selectedIndex = args.index;

this._updateSelectedValue(object);
}

this.closeCallback(args.view, args.index);
}

Expand Down

0 comments on commit 94ad41b

Please sign in to comment.