optimistex/ngx-select-ex

typed event is not firing when text is cleared when closed

Opened this issue · 0 comments

Describe the bug
Using a template for dropdown items, I used a multiline text to show the text and a description. I used the search Callback to search also in the description. I want also to highlight the searched text in the description. Using the typed event I can do that, but this event is not fired when the dropdown is closed and the input text is cleared, so closing and opening the dropdown after a search is performed, ends with highlighted text in the description with no search value.

To Reproduce
https://codesandbox.io/s/compassionate-tdd-rbd1j?file=/src/app/app.component.html

Expected behavior
typed event should fire also when text is cleared.

Note: I can fix that easily with this:

this.inputElRef.nativeElement.value = null;
this.typed.emit(''); // add this line

However, this event is also being listened in the component itself and it triggers too many things that shouldn't be called in such case. Maybe the solution is to separate the internal flow to be triggered by an internal subject that won't be fired in such case, and use the typed event just for outer listeners.