question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Provide way to keep search text when calling `close()`

See original GitHub issue

Expected behaviour

There should be a way to keep the search text when closing the drop-down programmatically with close().

Actual behaviour

The search text is cleared on close:

close() {
  if (!this.isOpen || this._manualOpen) {
    return;
  }
  this.isOpen = false;
  this._clearSearch(); // <<<< this line
  this._onTouched();
  this.closeEvent.emit();
  this._cd.markForCheck();
}

More Info


This could be linked to issue #678. The problem seems to be that [clearSearchOnAdd] is too specific and the only way to control the search text. I can think of a few potential solutions:

  • Provide an extra input like [clearSearchOnClose].
  • Rename the input to [clearSearch], use it for both adding and closing (so they can both be turned off), and expose a clearSearch() method.
  • Make the search text controllable from the outside, just like the open/closed state, perhaps through two-way binding of [(typeahead)]. That’d be ideal but, I assume, very complex.

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Reactions:8
  • Comments:10 (2 by maintainers)

github_iconTop GitHub Comments

6reactions
axelboccommented, Jul 12, 2018

I’m using it as a picker with autocomplete. As soon as an option is selected and the dropdown is closed, I store the selection myself then clear the dropdown’s model. The dropdown never holds a value (well, not for long).

Once the dropdown is closed, I’d like the search to be persisted so I can pick another option. I’m able to keep the options, but the search term gets cleared.

Does it make sense?

4reactions
varnastadeuscommented, Aug 31, 2018
<ng-select
    #select
    [items]="items"
    (close)="select.filterValue = searchTerm"
    (input)="searchTerm = select.filterValue"
    [(ngModel)]="selected">
</ng-select>

I still don’t see this behaviour as normal, but you can preserve search term this way. Also I would like to see some working example so it would be easier to understand your use case.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Help protect your family with Family settings - Google Fi Help
Under “Help protect (member's name) Families,” tap Only receive calls and texts from your phone contacts. Turn on or off Only receive calls...
Read more >
Place Search | Places API - Google Developers
There is no way to constrain Nearby Search or Text Search to only return specific fields. To keep from requesting (and paying for)...
Read more >
Add and use contact information on iPhone - Apple Support
(To turn this feature off, go to Settings > Contacts > Siri & Search, then turn off Show Siri Suggestions for Contacts.) Based...
Read more >
Ranking Results – How Google Search Works
How results are automatically generated ... A Search bar with the query "hair salon near me". Key factors in your results.
Read more >
1. Language Processing and Python - NLTK
What tools and techniques does the Python programming language provide ... This bracketed material is known as a list in Python: it is...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found