-
-
Notifications
You must be signed in to change notification settings - Fork 241
Description
From @konradkubiec on December 12, 2016 11:15
Did you verify this is a real problem by searching [Stack Overflow]
Yes. I didn't find any information about this issue.
Which platform(s) does your issue occur on?
Both Android and iOS
Please provide the following version numbers that your issue occurs with:
- CLI: 2.4.0
- Cross-platform modules: 2.3.0
"nativescript": {
"platforms": {
"ios": "2.1.1",
"android": "2.1.1"
}
}
- Runtime(s):
"tns-ios": {
"version": "2.4.0"
},
"tns-android": {
"version": "2.4.1"
}
Please tell us how to recreate the issue in as much detail as possible.
Use given example code. Function testValFunc called by ngModelChanage should:
- remove all non-digit characters from event string
- assign modified string to testVal component's property
As a result, TextField should have a new text value (testVal).
Test case:
Writing 1234abd
cause testVal change (correct logs in console) but not TextField text property update.
When you write an additional number (e.g. 3
, so new text is 1234abd3
) only then TextField text property is updated (new value: 12343
).
On Android, text cursor jumps to position 0 (beginning of the text). On iOS it stays at the end of a text. If I remind it right, in CLI 2.3.0, it was opposite. In my opinion, it should go to the text end as default for both platforms.
Is there code involved? If so, please share the minimal amount of code needed to recreate the problem.
XML (app.component.html):
<StackLayout>
<TextField [ngModel]='testVal' (ngModelChange)='testValFunc($event)'></TextField>
</StackLayout>
TS:
import { Component } from "@angular/core";
import { View } from "ui/core/view";
import { TextField } from "ui/text-field";
@Component({
selector: "my-app",
templateUrl: "app.component.html",
styleUrls: ["app-common.css"]
})
export class EnterComponent {
testVal: string;
testValFunc(str:string){
str = str.replace(/[^\d]/g, '');
this.testVal = str;
console.log(this.testVal);
}
}
Copied from original issue: NativeScript/NativeScript#3282