ProgressNS / nativescript-ui-feedback

This repository is used for customer feedback regarding Telerik UI for NativeScript. The issues system here is used by customers who want to submit their feature requests or vote for existing ones.
Other
115 stars 21 forks source link

AutoCompleteTextView suggestion view becomes visible by default without searching #1455

Open kandangit opened 4 years ago

kandangit commented 4 years ago

Tell us about the problem

The suggestion view for the autocomplete field is visible by default just after the text field is set.

COMPONENT:

@ViewChild("conceptAutocomplete", {
  static: true
})
autocompleteField: RadAutoCompleteTextViewComponent;

// ....

// Called from ngOnChanges when the input object is provided with a new value:
private setFormWithObject(object) {
  this.autocompleteField.autoCompleteTextView.text = object.name;
}

TEMPLATE:

<RadAutoCompleteTextView #autocompleteField [items]="autocompleteItems" displayMode="Plain" completionMode="Contains"
    (didAutoComplete)="onDidAutoComplete($event)" (focus)="onAutoCompleteFocus($event)">
    <SuggestionView tkAutoCompleteSuggestionView suggestionViewHeight="150">
        <ng-template tkSuggestionItemTemplate let-item="item">
            <StackLayout orientation="horizontal" padding="5">
                <Label [text]="item.line.name"></Label>
            </StackLayout>
        </ng-template>
    </SuggestionView>
</RadAutoCompleteTextView>

How to make the suggestion view only appear when the text field actually changes or get the focus?

My guess is that changing the text property by code actually creates a focus on the element and the search of suggestions is triggered and the view is displayed.

WORKAROUND NOTE A workaround found is to initialize (inside ngOnInit) minimumCharactersToSearch to a high number and change it on the focus event:

onAutoCompleteFocus(event) {
   this.autocompleteField.nativeElement.minimumCharactersToSearch = 2;
}

I have tried on the onLoad event: event.object.suggestionView.android.visibility = "hidden"; This works but when I do on the focus event: event.object.suggestionView.android.visibility = "visible"; The suggestion view no longer becomes visible.

Which platform(s) does your issue occur on?

Android

Please provide the following version numbers that your issue occurs with: