Skip to content
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

Select2 Still showing options IF disabled after hitting spacebar #5156

Closed
William-H-M opened this issue Dec 6, 2017 · 1 comment
Closed

Comments

@William-H-M
Copy link

While the select is disabled it's still possible to select an option IF the spacebar is hit with the select being in focus.

This will happen with either single or multiple select
https://jsfiddle.net/William_/9pqh3m63/1/

Steps to reproduce:

  1. Disable the selects
  2. Set focus on select and hit SPACEBAR.

This will open the select and allow you to select an option.

Select2 versions used:
From 4.05 to 4.0.6-rc.1
Version used on fiddle: 4.0.5-rc.0

Browsers used:
Firefox 57.0.1 (64-bit)
Chrome Version 62.0.3202.94 (64 bits)

Operation system: Windows 10 Build 1709

DISCLAIMER: I'm NOT the original reporter of the bug this was found at SO question

There's a workaround provided in one of the answers but for it to work it must be used the select2.full.min

In case of the link being dead answer provided here:

$('#select2').select2({
  containerCssClass: 'mysel-con',
  placeholder: 'Select an option'
});

$('#select2Multiple').select2({
  placeholder: 'Select an option',
});

$('#disableBtn').on('click', function() {
  $('#select2').select2('enable', false);
  $('#select2Multiple').select2('enable', false);
  $('.mysel-con').css('pointer-events', 'none');
});

$('#enableBtn').on('click', function() {
  $('#select2').select2('enable');
  $('#select2Multiple').select2('enable');
  $('.mysel-con').css('pointer-events');
});

Thanks to @beaver71 for the workaround.

@alexweissman
Copy link
Contributor

I believe this is a duplicate of #4695 (or at the very least, likely the same underlying problem).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants