Ng-select: selectOnClose, don't lose what the user typed in when clicking away

Created on 3 Nov 2020  路  3Comments  路  Source: ng-select/ng-select

Is your feature request related to a problem? Please describe.
Native dropdown will select the option when closing, no need to press TAB or ENTER. I would love to see something like [selectOnClose] for the item that is currently marked. Or whatever is highlighted is selected immediately (instead of just being "marked")

So for instance, if I filter down the dropdown with typed in text, when I click out of the dropdown I would love that it stays selected.
One of the annoying thing is if we allow also custom text to be written with [addTag], typing the text and having the only option "Add item ABCDEF" highlighted, clicking out just clears out the whole thing.

Now, I saw someone proposing a solution here
https://github.com/ng-select/ng-select/issues/687

However, it's quite a hacked solution because we have to handle 2 events to support this functionality; and it doesn't work well based on the [bindValue]. The close() method clears out important piece of data before the event onClose() is called.

Describe the solution you'd like

  • A [selectOnClose] which selects whatever markedItem is highlighted (including the tags if [addTag] is active), OR
  • Anything marked should be reflected in the model value, so pressing down arrow would actually change the value. This would behave a little more like a native dropdown, but would be quite complete to handle when typing and ending up with nothing selectable.

Describe alternatives you've considered
https://github.com/ng-select/ng-select/issues/687 ?

stale

Most helpful comment

I would love if this were to be implemented.

All 3 comments

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions :fireworks:

I would love if this were to be implemented.

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions :fireworks:

Was this page helpful?
0 / 5 - 0 ratings