mirror of
https://github.com/NativeScript/NativeScript.git
synced 2025-11-05 13:26:48 +08:00
Merge pull request #4292 from NativeScript/fix-ios-text-view-hint
Fix: IOS text view hint should never show while editing
This commit is contained in:
4
apps/app/ui-tests-app/issues/issue-3354.ts
Normal file
4
apps/app/ui-tests-app/issues/issue-3354.ts
Normal file
@@ -0,0 +1,4 @@
|
|||||||
|
export function clear(args) {
|
||||||
|
const tv = args.object.page.getViewById("tv");
|
||||||
|
tv.text= "";
|
||||||
|
}
|
||||||
6
apps/app/ui-tests-app/issues/issue-3354.xml
Normal file
6
apps/app/ui-tests-app/issues/issue-3354.xml
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
<Page xmlns="http://schemas.nativescript.org/tns.xsd">
|
||||||
|
<StackLayout class="p-20">
|
||||||
|
<TextView id="tv" text="" hint="the hint" ></TextView>
|
||||||
|
<Button text="clear text" tap="clear"></Button>
|
||||||
|
</StackLayout>
|
||||||
|
</Page>
|
||||||
@@ -23,6 +23,7 @@ export function pageLoaded(args: EventData) {
|
|||||||
examples.set("1639", "issues/issue-1639");
|
examples.set("1639", "issues/issue-1639");
|
||||||
examples.set("1657-ios", "issues/issue-1657-ios");
|
examples.set("1657-ios", "issues/issue-1657-ios");
|
||||||
examples.set("tabview-with-scrollview_4022","issues/tabview-with-scrollview_4022");
|
examples.set("tabview-with-scrollview_4022","issues/tabview-with-scrollview_4022");
|
||||||
|
examples.set("3354-ios", "issues/issue-3354");
|
||||||
|
|
||||||
let viewModel = new SubMainPageViewModel(wrapLayout, examples);
|
let viewModel = new SubMainPageViewModel(wrapLayout, examples);
|
||||||
page.bindingContext = viewModel;
|
page.bindingContext = viewModel;
|
||||||
|
|||||||
@@ -28,6 +28,13 @@ class UITextViewDelegateImpl extends NSObject implements UITextViewDelegate {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public textViewDidBeginEditing(textView: UITextView) {
|
||||||
|
var owner = this._owner.get();
|
||||||
|
if (owner) {
|
||||||
|
owner._isEditing = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public textViewDidEndEditing(textView: UITextView) {
|
public textViewDidEndEditing(textView: UITextView) {
|
||||||
const owner = this._owner.get();
|
const owner = this._owner.get();
|
||||||
if (owner) {
|
if (owner) {
|
||||||
@@ -35,6 +42,7 @@ class UITextViewDelegateImpl extends NSObject implements UITextViewDelegate {
|
|||||||
textProperty.nativeValueChange(owner, textView.text);
|
textProperty.nativeValueChange(owner, textView.text);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
owner._isEditing = false;
|
||||||
owner.dismissSoftInput();
|
owner.dismissSoftInput();
|
||||||
owner._refreshHintState(owner.hint, textView.text);
|
owner._refreshHintState(owner.hint, textView.text);
|
||||||
}
|
}
|
||||||
@@ -63,6 +71,7 @@ export class TextView extends EditableTextBase implements TextViewDefinition {
|
|||||||
private _ios: UITextView;
|
private _ios: UITextView;
|
||||||
private _delegate: UITextViewDelegateImpl;
|
private _delegate: UITextViewDelegateImpl;
|
||||||
private _isShowingHint: boolean;
|
private _isShowingHint: boolean;
|
||||||
|
public _isEditing: boolean;
|
||||||
|
|
||||||
constructor() {
|
constructor() {
|
||||||
super();
|
super();
|
||||||
@@ -96,9 +105,10 @@ export class TextView extends EditableTextBase implements TextViewDefinition {
|
|||||||
if (this.formattedText) {
|
if (this.formattedText) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (text !== null && text !== undefined && text !== '') {
|
if (text !== null && text !== undefined && text !== '') {
|
||||||
this.showText();
|
this.showText();
|
||||||
} else if (hint !== null && hint !== undefined && hint !== '') {
|
} else if (!this._isEditing && hint !== null && hint !== undefined && hint !== '') {
|
||||||
this.showHint(hint);
|
this.showHint(hint);
|
||||||
} else {
|
} else {
|
||||||
this._isShowingHint = false;
|
this._isShowingHint = false;
|
||||||
|
|||||||
Reference in New Issue
Block a user