Opened 6 years ago
Closed 5 years ago
#31522 closed Cleanup/optimization (fixed)
FilteredSelectMultiple widget jumps to top when an option is added.
| Reported by: | Shai Berger | Owned by: | TapanGujjar |
|---|---|---|---|
| Component: | contrib.admin | Version: | dev |
| Severity: | Normal | Keywords: | |
| Cc: | TapanGujjar | Triage Stage: | Ready for checkin |
| Has patch: | yes | Needs documentation: | no |
| Needs tests: | no | Patch needs improvement: | no |
| Easy pickings: | yes | UI/UX: | yes |
Description
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 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.
Attachments (1)
Change History (11)
by , 6 years ago
| Attachment: | multiselect.tgz added |
|---|
comment:1 by , 6 years ago
| Component: | Uncategorized → contrib.admin |
|---|---|
| Easy pickings: | set |
| UI/UX: | set |
comment:2 by , 6 years ago
| Type: | Uncategorized → Bug |
|---|
comment:3 by , 6 years ago
| Owner: | changed from to |
|---|---|
| Status: | new → assigned |
comment:4 by , 6 years ago
| Summary: | FilteredSelectMultiple widget jumps to top when an option is added → FilteredSelectMultiple widget jumps to top when an option is added. |
|---|---|
| Triage Stage: | Unreviewed → Accepted |
| Type: | Bug → Cleanup/optimization |
comment:6 by , 6 years ago
| Patch needs improvement: | set |
|---|
comment:7 by , 6 years ago
| Cc: | added |
|---|
comment:8 by , 6 years ago
| Patch needs improvement: | unset |
|---|
https://github.com/django/django/pull/12833
All the tests have passed. Thank you @felixxm
comment:9 by , 5 years ago
| Triage Stage: | Accepted → Ready for checkin |
|---|
This project has a user "shai" with password "1" to log in to the admin in the included database