I think I did it! :)
The point is to prevent any other propagation on the option tag mousedown event, and manage manually the focusing of the select box.
See the jsFiddle
I tried to make it as clear as I can :
$('option')
.on('mousedown', function(e){
// Prevent any other propagations
e.stopImmediatePropagation();
// Focus on the select DOM element
// but saving the scrollTop of each parent before
$(this)
.parents()
.filter(function(){
// filter only those which have a scroll visible
return $(this)[0].scrollHeight > $(this)[0].clientHeight;
})
.each(function(_,elt){
// and for each, save the scroll value in data set
$(elt).data('saveScroll', $(elt).scrollTop());
})
// Then trigger the focus option of the select DOM element
// And finally the custom 'scrollback' event
$(this).parent('select')
.trigger('focus')
.trigger('scrollback');
});
$('select')
// This customized event is for getting back the value of the scroll of all parents
// only if this value exists
.on('scrollback'
, function(e){
$(this)
.parents()
.filter(function(){
// filter only those which have this data in data-set
return 0 === $(this).data('saveScroll') || ~~$(this).data('saveScroll');
})
.each(function(_,elt){
// and for each, putting back the right scroll value
$(elt).scrollTop($(elt).data('saveScroll'));
$(elt).removeData('saveScroll');
})
});
This is probably not perfect because it is a hack.
At least it even worked with multiple-typed select. And it is cross-browser compliant.
selectelement. If Chrome didn't scroll the parent element, only half of the options would ever be visible. You want to prevent Chrome from trying to display the entireselectelement?