ng2-ui / auto-complete

Angular Auto Complete component and directive
https://ng2-ui.github.io/dist/#/auto-complete
MIT License
279 stars 123 forks source link

how to clear selection with [accept-user-input]=false #301

Open crh225 opened 6 years ago

crh225 commented 6 years ago

IMPORTANT Please be specific with an example. An issue with no example may be closed.

Steps to reproduce and a minimal demo http://plnkr.co/edit/D7d8uHG9XQfpsV0LuqcG?p=preview

Current behavior step 1: select Asia step2: clear out textbox. step3: create a blur event by clicking outside the textbox step3: notice how it gets repopulated with Asia.

crh225 commented 6 years ago

this is separate from https://github.com/ng2-ui/auto-complete/issues/277, as I want to clear the value out completely.

crh225 commented 6 years ago

It appears it is related to a combination of [list-formatter]="autocompleListFormatter" and accept-user-input=false

crh225 commented 6 years ago

it seems to be related to this bit of code: if (_this.inputEl && hasRevertValue && _this.acceptUserInput === false && currentItem === null) { _this.selectNewValue(_this.revertValue); } else if (_this.inputEl && _this.acceptUserInput === true && typeof currentItem === "undefined" && event && event.target.value) { _this.enterNewText(event.target.value); }

almothafar commented 6 years ago

I think you need to use select-on-blur