-
Notifications
You must be signed in to change notification settings - Fork 912
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Pressing enter should open the dropdown when ng-select is focused #508
Comments
@SandeepThomas it only opens on windows so this behaviour isn't consistent among other OS's |
@varnastadeus yes, but is it possible to make it open the dropdown on enter key? |
ofcourse it is, but you need to handle it yourself. |
can you please guide on how to achieve that? i tried attaching a keyup event listener to open the dropdown if its closed, but that opens the dropdown after selecting a value also. |
<ng-select [items]="people$ | async"
bindLabel="name"
#select
bindValue="id"
(keydown.enter)="$event.stopImmediatePropagation(); select.toggle()"
[(ngModel)]="selectedPersonId">
</ng-select> here is an idea, ideally if select is open you need to to do nothing and if it is closed call |
Thanks, will try that tomorrow and post here the result. |
Also we will consider making it as a feature. |
Thanks @varnastadeus. I tried it in stackblitz and it seems to be working, will try in my original code tomorrow. Here is the link if any one is interested: https://stackblitz.com/edit/ng-select-example-3nwrql It also has option to change language dynamically without breaking search and highlight. |
@SandeepThomas I made change in our codebase. |
Oh, I see. Thanks buddy 👍 |
@varnastadeus i tried it in my project, but its triggering search while pressing enter! |
can you add reproducible example? I don't see it happen in demo page. |
Sorry, my bad. Its something to do with my code. |
@varnastadeus you can see my issue here: https://stackblitz.com/edit/ng-select-example-jl5swq Am changing the focus to another input on dropdown value change, but its triggering the keydown.enter in the new input. My use case involves a Phone Number input with ng-select to select country code and an input field to enter mobile number. So when a user selects a country code, i need to set focus automatically on the number field so that user can just enter the number and press enter to submit the form. |
use |
@varnastadeus Love your support, thank buddy. this is why i'm use ng-select ! |
I have updated angular from version 7 to 8 and now the stopImmediatePropagation() method on (keydown.enter) event is not working anymore. :/ Does anybody know how to prevent selecting the marked option on the enter key if the select's dropdown is closed? In my project I use: Thanks in advance! |
@varnastadeus, @dreamid27, @SandeepThomas guys can anybody help me? |
Expected behaviour
Pressing the enter key when ng-select is focused should open the dropdown if its closed like native select.
Actual behaviour
Pressing the enter key when ng-select is focused does nothing if its closed.
More Info
ng-select version: 1.3.0
browser: Chrome
reproducible in demo page: YES
The text was updated successfully, but these errors were encountered: