#31522: FilteredSelectMultiple widget jumps to top when an option is added
-----------------------------------------+------------------------
Reporter: Shai Berger | Owner: nobody
Type: Uncategorized | Status: new
Component: Uncategorized | Version: master
Severity: Normal | Keywords:
Triage Stage: Unreviewed | Has patch: 0
Needs documentation: 0 | Needs tests: 0
Patch needs improvement: 0 | Easy pickings: 0
UI/UX: 0 |
-----------------------------------------+------------------------
When using a FilteredSelectMultiple as a widget for a MultipleChoice
field, typically the list of options is longer than what fits in the
control. If the user then scrolls down, selects some options, and clicks
the arrow to move them to the "chosen" box, then they are correctly added,
but the "available" box scrolls to the top.
It would be much nicer if the "available" box stayed where it was.
At [https://www.matific.com Matific] where we encountered this, we
monkeypatched the control's media to add a JavaScript file with this code:
{{{
(function($){
if(!SelectBox)
return;
var oldRedisplay = SelectBox.redisplay;
if(typeof oldRedisplay !== 'function')
return;
SelectBox.redisplay = function(id) {
var top = $('#'+id).scrollTop(); //record current scroll
var res = oldRedisplay.apply(this, arguments);
$('#'+id).scrollTop(top); // Restore the scroll
return res;
};
})(django.jQuery);
}}}
I'm attaching a minimal project to demonstrate it.
--
Ticket URL: <https://code.djangoproject.com/ticket/31522>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
--
You received this message because you are subscribed to the Google Groups
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/django-updates/048.f145fed59c833017ae2a0d5358215286%40djangoproject.com.