-
-
Notifications
You must be signed in to change notification settings - Fork 6.3k
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
Feed back the keypress code that was responsible for the 'close' even… #5513
Conversation
…t s part of the event parameters
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. |
this would be really handy for a lot of use cases, folks! Very safe and small. Please consider. |
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. |
bump |
Just realized I never reviewed this one. Generally I'm okay with things like this being done (providing event context when we do things), but in the past we've done this by passing
select2/src/js/select2/results.js Line 464 in e5131d0
|
OK, makes sense, changes made... |
Thanks a bunch for making that change! This PR has been accepted for the next release of Select2 (likely 4.0.12) and will be merged in the near future once the most recent release has stabilized. |
Thanks, that's great! |
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. |
bump |
This is a great start, but I think it would make sense to include the original event on all triggers of the This one only works if the select closes from that small set of keyboard commands, but if it's closed via things like This feature is nice because I can observe the tab or shift-tab key being pressed to close the dropdown, but it doesn't work if |
I was simply using this for keyboard navigation in a grid. For example, I need to know if it was closed with an Enter (focus remains or go to next control), Tab (go to next control) or Shift-Tab (go to last control). |
That's the same use case for me actually.
Tab and shift+tab for forward and backward, but in my case enter should go
forward as well. And on top of that, both enter and tab should select the
highlighted option, which means I have to use SelectOnClose.
This enhancement covers some of these scenarios but I still can't get the
keycode to know when enter is pressed.
|
As always, we encourage further pull requests that expand this functionality out to more use cases. |
@joepetrakovich which grid? perhaps we should establish a simple test page? I'm using SlickGrid, but I don't suppose the grid really matters that much. |
@6pac yeah it probably doesn't matter. I'm using DevExpress's ASPxGridView in batch edit mode (https://demos.devexpress.com/ASPxGridViewDemos/GridEditing/BatchEditing.aspx). They have their own built in autocomplete dropdown but it's slow and clunky compared to Select2. If you add custom controls into the grid cells you have to re-implement the keyboard navigation. This commit made it a lot easier but like I said since the keypress event is lost in most other actions on the dropdown, I haven't gotten it fully fleshed out without weird non-compliant hacks. I may try my hand at a pull request. |
Feed back the keypress code that was responsible for the 'close' event as part of the event parameters. This is a non-breaking enhancement that doesn't affect any existing behaviour.