Opened 19 years ago

Closed 17 years ago

#348 closed defect (fixed)

[patch] Multiple clicks on "Choose all" or "Clear all" in the Javascript "filter" interface causes strange behavior

Reported by: rmunn@… Owned by: Adrian Holovaty
Component: contrib.admin Version:
Severity: normal Keywords:
Cc: Triage Stage: Accepted
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: yes
Easy pickings: no UI/UX: no

Description

I'm writing a simple contact-tracking application in Django. I have Person, Address, and Newsletter models. Newsletter is a many-to-many relation to Person, so that I can ask "Who got the June 2005 newsletter?" and "How many newsletters has John Smith missed?". I used the filter_interface option to tie Newsletter to Person in the admin interface. I then set up some test data to play around with the filter_interface, including three Persons: John Smith, Linda Jones, and Sophie Sophist (who lives at 123 Philosopher Lane, naturally).

Selecting individual people and clicking the left and right arrows moved names around just fine. No problems there. And single-clicking on the "Clear all" and "Choose all" worked as expected. Double-clicking on either "Clear all" or "Choose all", though, produced some weird results: all the names would move across, but then when moved back, a single name would get left behind. E.g.:

  • "Available persons" contains all three names.
  • Click on "Choose all". All three names move to "Chosen persons".
  • Click on "Choose all" a second time. No visible result.
  • Click on "Clear all". All three names move to "Available persons", but a second copy of Linda Jones is left behind.
  • Click on "Choose all". All three names from "Available persons" move over to "Chosen persons", and there are now four names (including two Linda Jones entries) in "Chosen persons".

Repeating such a procedure ends up yielding five names, then six, then seven, out of the original three. All of them act like real entries: I can select them one at a time and move them left or right, and they don't disappear.

Furthermore, if I click three or four or five times on "Choose all" before clicking on "Clear all", then two or three or four names get left behind when I finally do click "Clear all".

This also works in reverse, e.g. if I click "Clear all" multiple times and then click "Choose all", it will also leave some names behind.

If I leave one side or the other ("Chosen persons" or "Available persons") empty, the correct values seem to go into the database: it only creates one row in the multiple-join table even though there are ten copies of Linda Jones present in "Chosen persons", for example. But if a name is present in both "Chosen persons" and "Available persons", "Chosen" wins. A single copy of John Smith in "Chosen persons" trumps a dozen John Smiths in "Available persons".

I can reproduce this bug consistently using Firefox 1.0.6 on Ubuntu Breezy, and Firefox 1.0.6 on Mac OS X 10.3.9.

Attachments (1)

348.diff (889 bytes ) - added by Gary Wilson <gary.wilson@…> 18 years ago.

Download all attachments as: .zip

Change History (6)

by Gary Wilson <gary.wilson@…>, 18 years ago

Attachment: 348.diff added

comment:1 by Gary Wilson <gary.wilson@…>, 18 years ago

Summary: Multiple clicks on "Choose all" or "Clear all" in the Javascript "filter" interface causes strange behavior[patch] Multiple clicks on "Choose all" or "Clear all" in the Javascript "filter" interface causes strange behavior

Didn't look to see if anything was going on with SelectBox.cache, but doing the cache_contains() check in move_all(), which move() was doing, seems to make things better.

comment:2 by Gary Wilson <gary.wilson@…>, 18 years ago

The "New faster SelectBox.js" patch attached to #3099 also fixes this.

comment:3 by Marc Fargas <telenieko@…>, 18 years ago

The references #3099 is markes as duplicate of #3202. Can somebody confirm if the patch in there would solve this ticket? Or if the bug is still reproducible (it's 1 year old).

in reply to:  3 comment:4 by Gary Wilson <gary.wilson@…>, 18 years ago

Patch needs improvement: set
Triage Stage: UnreviewedAccepted

Replying to Marc Fargas <telenieko@telenieko.com>:

The references #3099 is markes as duplicate of #3202. Can somebody confirm if the patch in there would solve this ticket? Or if the bug is still reproducible (it's 1 year old).

This bug is still reproducible, please see this comment I made in #3202.

comment:5 by Adrian Holovaty, 17 years ago

Resolution: fixed
Status: newclosed

(In [6015]) Fixed #348 -- Fixed bug in admin JavaScript filter interface. Thanks for the patch, Gary Wilson

Note: See TracTickets for help on using tickets.
Back to Top