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

Higlighted Item Problem [MultiSelect with closeOnSelect=false] #4584

Closed
7 tasks done
BonDoQ opened this issue Sep 14, 2016 · 3 comments
Closed
7 tasks done

Higlighted Item Problem [MultiSelect with closeOnSelect=false] #4584

BonDoQ opened this issue Sep 14, 2016 · 3 comments

Comments

@BonDoQ
Copy link

BonDoQ commented Sep 14, 2016

Steps to reproduce the issue

  1. Select an element for the top of the list.
  2. Scroll down and select the last Element

Expected behaviour

dropdown still at the same scroll position

Actual behaviour

dropdown scroll up to highlight the first "selected" Item

Environment

Browsers

  • Google Chrome
  • Mozilla Firefox
  • Internet Explorer

Operating System

  • Windows
  • Mac OS X
  • Linux
  • Mobile

Libraries

  • jQuery version: 3.1.0
  • Select2 version: 4.0.3

Isolating the problem

  • [x ] I can reproduce this bug in a (JSFiddle)

Could be a Solution

check this condition before trigger that function would prevent the behaviour for that case

result.js:279

if(!(self.options.get('multiple') && !self.options.get('closeOnSelect'))) {
  self.highlightFirstItem();
}

also for the unselect

@kevin-brown
Copy link
Member

Duplicate of #4417.

@alexweissman
Copy link
Contributor

Please see #4417 (comment) to understand where this bug came from.

@hemant-rao
Copy link

this code working fine for my side, I hope this will help you.

$('#selectmultiple').select2({
closeOnSelect: false
})
.on('select2:selecting', e => $(e.currentTarget).data('scrolltop', $('.select2-results__options').scrollTop()))
.on('select2:select', e => $('.select2-results__options').scrollTop($(e.currentTarget).data('scrolltop')));

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

No branches or pull requests

4 participants