FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

Feed back the keypress code that was responsible for the 'close' even… by 6pac · Pull Request #5513 · select2/select2 · GitHub

Feed back the keypress code that was responsible for the 'close' even… - #5513

Merged
kevin-brown merged 2 commits into
select2:developfrom
6pac:6pac-close-keypress
Jan 28, 2020
Merged

Feed back the keypress code that was responsible for the 'close' even…#5513
kevin-brown merged 2 commits into
select2:developfrom
6pac:6pac-close-keypress

Conversation

6pac commented May 16, 2019

Copy link
Copy Markdown
Contributor

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.

stale Bot commented Jul 15, 2019

Copy link
Copy Markdown

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.

stale Bot added the status: stale label Jul 15, 2019

6pac commented Jul 15, 2019

Copy link
Copy Markdown
Contributor Author

this would be really handy for a lot of use cases, folks! Very safe and small. Please consider.

stale Bot removed the status: stale label Jul 15, 2019

stale Bot commented Sep 13, 2019

Copy link
Copy Markdown

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.

stale Bot added the status: stale label Sep 13, 2019

6pac commented Sep 13, 2019

Copy link
Copy Markdown
Contributor Author

bump

stale Bot removed the status: stale label Sep 13, 2019

Copy link
Copy Markdown
Member

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 originalEvent pointing to the original event which caused this action. This would be compatible with what you're looking for (getting the triggered keypress from the close event) while also maintaining consistency

originalEvent: evt

originalEvent: evt,

originalEvent: evt,

6pac commented Oct 14, 2019

Copy link
Copy Markdown
Contributor Author

OK, makes sense, changes made...

Copy link
Copy Markdown
Member

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.

6pac commented Oct 14, 2019

Copy link
Copy Markdown
Contributor Author

Thanks, that's great!

kevin-brown modified the milestones: 4.0.12, 4.0.13 Nov 6, 2019

stale Bot commented Jan 5, 2020

Copy link
Copy Markdown

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.

stale Bot added the status: stale label Jan 5, 2020

6pac commented Jan 5, 2020

Copy link
Copy Markdown
Contributor Author

bump

stale Bot removed the status: stale label Jan 5, 2020
kevin-brown merged commit 3b69d35 into select2:develop Jan 28, 2020

Copy link
Copy Markdown
Contributor

This is a great start, but I think it would make sense to include the original event on all triggers of the close event.

This one only works if the select closes from that small set of keyboard commands, but if it's closed via things like selectOnClose or the many other calls to self.close or trigger('close'), the original event is missing.

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 selectOnClose is enabled, and there is still no way to see if the enter key was pressed. Also, if the user selects the original value that was already selected, the close event is trigger but the original event is missing.

6pac commented Jan 30, 2020

Copy link
Copy Markdown
Contributor Author

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).

joepetrakovich commented Jan 30, 2020 via email
edited by kevin-brown
Loading

Copy link
Copy Markdown
Contributor

Copy link
Copy Markdown
Member

As always, we encourage further pull requests that expand this functionality out to more use cases.

6pac commented Jan 30, 2020

Copy link
Copy Markdown
Contributor Author

@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.

Copy link
Copy Markdown
Contributor

@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.

maxwellfet928 pushed a commit to maxwellfet928/select2 that referenced this pull request Jun 8, 2026
select2#5513)

* Feed back the keypress code that was responsible for the 'close' event s part of the event parameters

* Update core.js
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants


Back | FazBrowse Home | New Git URL