| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
…highlighted option to be consistent with regular html selects in modern browsers.
|
I just realized this may be a breaking change for a lot of people. If they've gone this long using select2 with the assumption that TAB should not select, changing it may mess their surrounding navigation code up. One scenario I found is when the user tabs to the dropdown, I have the dropdown automatically open up so they can start typing, but when you call open, the first option is already highlighted, so if you hit TAB again (with the desire to skip the field and leave it blank), you can't do it because it will now select that first highlighted option. You'd be forced to use the mouse to then clear it. This reminds me of the other issues that mention the desire for a blank first option. |
Sorry, something went wrong.
We have a minor release coming up soon which will feature some of these small-but-important somewhat-breaking changes so I'm comfortable knowing that.
Custom UX behaviours aren't our concern.
Good news! This is one of the places where Select2 is accessible through a keyboard. select2/src/js/select2/selection/allowClear.js Lines 87 to 89 in 51be56a
A fun feature request which could help here is to provide the keyboard event data to the select event, so you could detect that case and prevent the selection. |
Sorry, something went wrong.
|
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. |
Sorry, something went wrong.
@joepetrakovich thx i appreciate the PR. question: is there a way of adding the minor code changes in your PR so that it overrides the existing functionality in src/js/select2/core.js? any pointers would be much appreciated. |
Sorry, something went wrong.
|
@BKSpurgeon if you use the non-minified version of the library you can just do a text search for some of the lines I changed (like key === KEYS.ESC) and make the same change yourself. Is that what you are asking? |
Sorry, something went wrong.
|
Hi @joepetrakovich appreciate the response. Was wanting to know if there was a way to quickly override the original core functionality provided by select2: (i'm getting it from a yarn / npm package so presumably that package is not minified): if that is true, then is there a way to retain the original package and specifically override those 1 or 2 lines of code? |
Sorry, something went wrong.
|
@BKSpurgeon In the intermediate, I've been using using the events system: mySelect2Widget.on('select2:select', function (e) {
$(this).focus();
}); |
Sorry, something went wrong.
@devkinetic thx - do you have the context / larger code snippet of where to place the code? Not sure if i'm doing the right thing, but i couldn't get the above to work. |
Sorry, something went wrong.
|
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. |
Sorry, something went wrong.
|
@BKSpurgeon Sorry, i don't check github as often as I should. To follow up from my example mySelect2Widget is selector for an element with select2() applied to it. var mySelect2Widget = $('.css-class-to-target');
mySelect2Widget.on('select2:select', function (e) {
$(this).focus();
}); |
Sorry, something went wrong.
|
Reopening this for another stale cycle before the next release. Need to double check on ARIA for this before reviewing it. |
Sorry, something went wrong.
|
ARIA has zero guidance on this front so I'm going to default back to selectWoo and how the browser implements it. So this PR looks good and will land for the 4.1.0 release candidate. |
Sorry, something went wrong.
|
I noticed that if you navigate through web form with TAB keys (ARIA behaviour) and you are landing on select2 (multiple items) you get stacked in select2. TAB doesn't allow you to get to the next form field. This shouldn't happen. I'm missing something? |
Sorry, something went wrong.
| Back | FazBrowse Home | New Git URL |
Changed tab key press to behave the same as enter key and select the highlighted option. This is consistent with modern browser behavior for <select> elements.
#4820