Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions apps/app/ui-tests-app/issues/issue-3354.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
export function clear(args) {
const tv = args.object.page.getViewById("tv");
tv.text= "";
}
6 changes: 6 additions & 0 deletions apps/app/ui-tests-app/issues/issue-3354.xml
Original file line number Diff line number Diff line change
@@ -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>
1 change: 1 addition & 0 deletions apps/app/ui-tests-app/issues/main-page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ export function pageLoaded(args: EventData) {
examples.set("1639", "issues/issue-1639");
examples.set("1657-ios", "issues/issue-1657-ios");
examples.set("tabview-with-scrollview_4022","issues/tabview-with-scrollview_4022");
examples.set("3354-ios", "issues/issue-3354");

let viewModel = new SubMainPageViewModel(wrapLayout, examples);
page.bindingContext = viewModel;
Expand Down
14 changes: 12 additions & 2 deletions tns-core-modules/ui/text-view/text-view.ios.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import {
EditableTextBase, editableProperty, hintProperty, textProperty, colorProperty, placeholderColorProperty,
borderTopWidthProperty, borderRightWidthProperty, borderBottomWidthProperty, borderLeftWidthProperty,
paddingTopProperty, paddingRightProperty, paddingBottomProperty, paddingLeftProperty,
paddingTopProperty, paddingRightProperty, paddingBottomProperty, paddingLeftProperty,
Length, _updateCharactersInRangeReplacementString, Color, layout
} from "../editable-text-base";

Expand All @@ -28,13 +28,21 @@ class UITextViewDelegateImpl extends NSObject implements UITextViewDelegate {
return true;
}

public textViewDidBeginEditing(textView: UITextView) {
var owner = this._owner.get();
if (owner) {
owner._isEditing = true;
}
}

public textViewDidEndEditing(textView: UITextView) {
const owner = this._owner.get();
if (owner) {
if (owner.updateTextTrigger === "focusLost") {
textProperty.nativeValueChange(owner, textView.text);
}

owner._isEditing = false;
owner.dismissSoftInput();
owner._refreshHintState(owner.hint, textView.text);
}
Expand Down Expand Up @@ -63,6 +71,7 @@ export class TextView extends EditableTextBase implements TextViewDefinition {
private _ios: UITextView;
private _delegate: UITextViewDelegateImpl;
private _isShowingHint: boolean;
public _isEditing: boolean;

constructor() {
super();
Expand Down Expand Up @@ -96,9 +105,10 @@ export class TextView extends EditableTextBase implements TextViewDefinition {
if (this.formattedText) {
return;
}

if (text !== null && text !== undefined && text !== '') {
this.showText();
} else if (hint !== null && hint !== undefined && hint !== '') {
} else if (!this._isEditing && hint !== null && hint !== undefined && hint !== '') {
this.showHint(hint);
} else {
this._isShowingHint = false;
Expand Down