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

Select List Jumping to The Top When Clicking On Scrolled Items #70

Open
farzadso opened this issue Nov 13, 2016 · 8 comments
Open

Select List Jumping to The Top When Clicking On Scrolled Items #70

farzadso opened this issue Nov 13, 2016 · 8 comments
Assignees
Labels

Comments

@farzadso
Copy link

Initially I would like to thank you for your contribution.

I have discovered an issue and it happens when I click on List Items below the list, it jumps up to the top of the list as you can see in the gif below :
animation

@nbuytaert1 nbuytaert1 self-assigned this Nov 15, 2016
@nbuytaert1
Copy link
Owner

I'm afraid that's a bug in the Select2 jQuery plugin.
More information here: select2/select2#1513

There's a hacky fix to prevent the jump. Execute the following JavaScript code on page load:

var scrollTop;
$('#P10_MY_SELECT2_ITEM').on('select2:selecting select2:unselecting', function(event) {
  var $pr = $('#'+event.params.args.data._resultId).parent();
  scrollTop = $pr.prop('scrollTop');
});
$('#P10_MY_SELECT2_ITEM').on('select2:select select2:unselect', function(event) {
  var $pr = $('#'+event.params.data._resultId).parent();
  $pr.prop('scrollTop', scrollTop);
});

Replace P10_MY_SELECT2_ITEM with the name of your Select2 page item.

@nbuytaert1 nbuytaert1 added the bug label Nov 16, 2016
@farzadso
Copy link
Author

just tested, it still happens

@farzadso
Copy link
Author

could it be due to the fact that i'm using lazy loading?

animation

@farzadso
Copy link
Author

farzadso commented Dec 6, 2016

sorry for messaging again, any updates?

@nbuytaert1
Copy link
Owner

Sorry for the delay.
You are right, the fix doesn't work in combination with lazy loading.
I have no other solution for the moment. It's a bug in the Select2 plugin, which makes it difficult for me to fix.

@shawty
Copy link

shawty commented Apr 10, 2017

Just for reference, this is ALSO happening with non multiple select drop downs.

@farzadso
Copy link
Author

I've gone through the entire source code over and over again. Modified it in several places. I can't find a workaround @shawty

@Inzy07
Copy link

Inzy07 commented Jun 23, 2018

click event is not working in apex2 plugin
can anyone tell me quick fix for this?

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

No branches or pull requests

4 participants