[Django] #30459: If a StackedInline has fieldsets with the "collapsed" class, the "Show" link doesn't work on inline forms added with the "Add another [inline object]" link

20 views
Skip to first unread message

Django

unread,
May 7, 2019, 4:00:47 PM5/7/19
to django-...@googlegroups.com
#30459: If a StackedInline has fieldsets with the "collapsed" class, the "Show"
link doesn't work on inline forms added with the "Add another [inline
object]" link
------------------------------------------------+------------------------
Reporter: Antonis Christofides | Owner: nobody
Type: Bug | Status: new
Component: contrib.admin | Version: 2.2
Severity: Normal | Keywords:
Triage Stage: Unreviewed | Has patch: 0
Needs documentation: 0 | Needs tests: 0
Patch needs improvement: 0 | Easy pickings: 0
UI/UX: 1 |
------------------------------------------------+------------------------
I attach a screenshot with explanations, which is the easiest way to get a
grip of this problem.

Steps to reproduce the problem illustrated in the screenshot:

1. Create a {{{myblog}}} django project and a {{{blog}}} app.

2. Specify this {{{models.py}}} in the {{{blog}}} app:
{{{
from django.db import models

class BlogPost(models.Model):
content = models.TextField()


class Author(models.Model):
blog_post = models.ForeignKey(BlogPost, on_delete=models.CASCADE)
name = models.CharField(max_length=100)
birthday = models.DateField(blank=True)
}}}

3. Specify this {{{admin.py}}}:
{{{
from django.contrib import admin

from . import models


class AuthorInline(admin.StackedInline):
model = models.Author
extra = 1
fieldsets = [
("Essential", {"fields": ("name",), "classes": ("collapse",)}),
("Advanced", {"fields": ("birthday",), "classes": ("collapse",)}),
]


@admin.register(models.BlogPost)
class BlogPostAdmin(admin.ModelAdmin):
inlines = [AuthorInline]
}}}

4. Add the {{{blog}}} app to {{{INSTALLED_APPS}}}, makemigrations,
migrate, createsuperuser, runserver.

5. Visit /admin/, login, go to "Blog posts", click on "Add new blog post",
then click on "Add new Author".

Result: The "Show" links on the new Author form don't work. See the
screenshot for more information.

--
Ticket URL: <https://code.djangoproject.com/ticket/30459>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

Django

unread,
May 7, 2019, 4:01:17 PM5/7/19
to django-...@googlegroups.com
#30459: If a StackedInline has fieldsets with the "collapsed" class, the "Show"
link doesn't work on inline forms added with the "Add another [inline
object]" link
-------------------------------------+-------------------------------------
Reporter: Antonis | Owner: nobody
Christofides |

Type: Bug | Status: new
Component: contrib.admin | Version: 2.2
Severity: Normal | Resolution:

Keywords: | Triage Stage:
| Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 1
-------------------------------------+-------------------------------------
Changes (by Antonis Christofides):

* Attachment "Selection_011.png" added.

Screenshot that illustrates the problem

Django

unread,
May 8, 2019, 3:11:41 PM5/8/19
to django-...@googlegroups.com
#30459: If a StackedInline has fieldsets with the "collapsed" class, the "Show"
link doesn't work on inline forms added with the "Add another [inline
object]" link
-------------------------------------+-------------------------------------
Reporter: Antonis | Owner: nobody
Christofides |
Type: Bug | Status: new
Component: contrib.admin | Version: 2.2
Severity: Normal | Resolution:

Keywords: | Triage Stage:
| Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 1
-------------------------------------+-------------------------------------

Comment (by ruchit2801):

I could not reproduce this. See this screencast, both the links in my case
works properly. Pardon me if did something wrong, or misunderstood
something

--
Ticket URL: <https://code.djangoproject.com/ticket/30459#comment:1>

Django

unread,
May 8, 2019, 3:19:10 PM5/8/19
to django-...@googlegroups.com
#30459: If a StackedInline has fieldsets with the "collapsed" class, the "Show"
link doesn't work on inline forms added with the "Add another [inline
object]" link
-------------------------------------+-------------------------------------
Reporter: Antonis | Owner: nobody
Christofides |
Type: Bug | Status: new
Component: contrib.admin | Version: 2.2
Severity: Normal | Resolution:

Keywords: | Triage Stage:
| Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 1
-------------------------------------+-------------------------------------
Changes (by ruchit2801):

* Attachment "Screenshot 2019-05-09 at 12.47.34 AM.png" added.

Django

unread,
May 9, 2019, 4:23:28 AM5/9/19
to django-...@googlegroups.com
#30459: If a StackedInline has fieldsets with the "collapsed" class, the "Show"
link doesn't work on inline forms added with the "Add another [inline
object]" link
--------------------------------------+------------------------------------

Reporter: Antonis Christofides | Owner: nobody
Type: Bug | Status: new
Component: contrib.admin | Version: 2.2
Severity: Release blocker | Resolution:
Keywords: | Triage Stage: Accepted

Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 1
--------------------------------------+------------------------------------
Changes (by Carlton Gibson):

* severity: Normal => Release blocker
* stage: Unreviewed => Accepted


Comment:

OK, yes. Thanks for the report

This a regression in ba83378a7762c51be235b521aa5b48233d6c6c82, which was
part of Django v2.2.
(Reproduced at af5ec222ccd24e81f9fec6c34836a4e503e7ccf7)

The change from using [http://api.jquery.com/on/ jQuery's `on()`] did not
correctly account for the _delegation_ of event handlers.
Instead of attaching directly to the `a.collapse-toggle` elements (which
in this case do not exist in the DOM at when the listener is added) we
should attach to a parent element and filter events by the event target
class (as jQuery does/did for us).

--
Ticket URL: <https://code.djangoproject.com/ticket/30459#comment:2>

Django

unread,
May 9, 2019, 2:42:23 PM5/9/19
to django-...@googlegroups.com
#30459: If a StackedInline has fieldsets with the "collapsed" class, the "Show"
link doesn't work on inline forms added with the "Add another [inline
object]" link
--------------------------------------+------------------------------------

Reporter: Antonis Christofides | Owner: nobody
Type: Bug | Status: new
Component: contrib.admin | Version: 2.2
Severity: Release blocker | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 1
--------------------------------------+------------------------------------

Comment (by Claude Paroz):

Are you sure that's the regression? Looking at the code, jQuery was also
directly attaching the handler to the `a` link (`$("fieldset.collapse a
.collapse-toggle").on('click', function(ev) {`).

--
Ticket URL: <https://code.djangoproject.com/ticket/30459#comment:3>

Django

unread,
May 10, 2019, 6:18:48 AM5/10/19
to django-...@googlegroups.com
#30459: If a StackedInline has fieldsets with the "collapsed" class, the "Show"
link doesn't work on inline forms added with the "Add another [inline
object]" link
--------------------------------------+------------------------------------

Reporter: Antonis Christofides | Owner: nobody
Type: Bug | Status: new
Component: contrib.admin | Version: 2.2
Severity: Release blocker | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 1
--------------------------------------+------------------------------------

Comment (by Carlton Gibson):

Hey Claude.

I've tested on both 2.1 and 2.2. It works on 2.1, but not 2.2.

I (manually) bisected to the referenced commit, using this history view:

https://github.com/django/django/commits/master/django/contrib/admin/static/admin/js

It works at a5f139236f930df06ae0642507530ca98081e2a9#diff-
6f61a4571a97f023bafaedabcadd5f54 but fails at the next commit
ba83378a7762c51be235b521aa5b48233d6c6c82#diff-
6f61a4571a97f023bafaedabcadd5f54 — so I pinned it to that. (It's the only
change that looks relevant.)

You are right about the `on()` call though... 🤔

I was going to write a `js_tests` case to reproduce this. I'll then be
able to actually `git bisect`.

--
Ticket URL: <https://code.djangoproject.com/ticket/30459#comment:4>

Django

unread,
May 11, 2019, 3:14:38 AM5/11/19
to django-...@googlegroups.com
#30459: If a StackedInline has fieldsets with the "collapsed" class, the "Show"
link doesn't work on inline forms added with the "Add another [inline
object]" link
--------------------------------------+------------------------------------

Reporter: Antonis Christofides | Owner: nobody
Type: Bug | Status: new
Component: contrib.admin | Version: 2.2
Severity: Release blocker | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 1
--------------------------------------+------------------------------------

Comment (by Claude Paroz):

Carlton, did you progress with the test or was it just an intention?

--
Ticket URL: <https://code.djangoproject.com/ticket/30459#comment:5>

Django

unread,
May 11, 2019, 5:28:07 AM5/11/19
to django-...@googlegroups.com
#30459: If a StackedInline has fieldsets with the "collapsed" class, the "Show"
link doesn't work on inline forms added with the "Add another [inline
object]" link
--------------------------------------+------------------------------------

Reporter: Antonis Christofides | Owner: nobody
Type: Bug | Status: new
Component: contrib.admin | Version: 2.2
Severity: Release blocker | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 1
--------------------------------------+------------------------------------

Comment (by Claude Paroz):

I think this has something to do with the jQuery `clone(true)` method
(called from `inlines.js`) which is supposed to also copy events from the
original DOM element. It may be that it doesn't work with vanilla JS
events? To be investigated.

--
Ticket URL: <https://code.djangoproject.com/ticket/30459#comment:6>

Django

unread,
May 11, 2019, 5:32:11 AM5/11/19
to django-...@googlegroups.com
#30459: If a StackedInline has fieldsets with the "collapsed" class, the "Show"
link doesn't work on inline forms added with the "Add another [inline
object]" link
--------------------------------------+------------------------------------

Reporter: Antonis Christofides | Owner: nobody
Type: Bug | Status: new
Component: contrib.admin | Version: 2.2
Severity: Release blocker | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 1
--------------------------------------+------------------------------------

Comment (by Carlton Gibson):

Hey Claude.

No, I haven’t got there yet. (Worked out where to put it but not actually
written it.)

My plan was to look at it next week (2019 WK20). If you beat me to it,
that is fine. 🙂

--
Ticket URL: <https://code.djangoproject.com/ticket/30459#comment:7>

Django

unread,
May 11, 2019, 6:42:50 AM5/11/19
to django-...@googlegroups.com
#30459: If a StackedInline has fieldsets with the "collapsed" class, the "Show"
link doesn't work on inline forms added with the "Add another [inline
object]" link
--------------------------------------+------------------------------------

Reporter: Antonis Christofides | Owner: nobody
Type: Bug | Status: new
Component: contrib.admin | Version: 2.2
Severity: Release blocker | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 1 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 1
--------------------------------------+------------------------------------
Changes (by Claude Paroz):

* has_patch: 0 => 1
* needs_tests: 0 => 1


Comment:

A [https://github.com/django/django/pull/11353 suggested fix], without
tests though.

--
Ticket URL: <https://code.djangoproject.com/ticket/30459#comment:8>

Django

unread,
May 11, 2019, 7:59:20 AM5/11/19
to django-...@googlegroups.com
#30459: If a StackedInline has fieldsets with the "collapsed" class, the "Show"
link doesn't work on inline forms added with the "Add another [inline
object]" link
--------------------------------------+------------------------------------

Reporter: Antonis Christofides | Owner: nobody
Type: Bug | Status: new
Component: contrib.admin | Version: 2.2
Severity: Release blocker | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 1 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 1
--------------------------------------+------------------------------------

Comment (by Carlton Gibson):

Awesome. Thanks Claude! I'm happy to add the test in the week. Super.

--
Ticket URL: <https://code.djangoproject.com/ticket/30459#comment:9>

Django

unread,
May 15, 2019, 3:34:01 AM5/15/19
to django-...@googlegroups.com
#30459: If a StackedInline has fieldsets with the "collapsed" class, the "Show"
link doesn't work on inline forms added with the "Add another [inline
object]" link
-------------------------------------+-------------------------------------
Reporter: Antonis | Owner: Carlton
Christofides | Gibson
Type: Bug | Status: assigned
Component: contrib.admin | Version: 2.2

Severity: Release blocker | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 1 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 1
-------------------------------------+-------------------------------------
Changes (by Carlton Gibson):

* status: new => assigned
* owner: nobody => Carlton Gibson


--
Ticket URL: <https://code.djangoproject.com/ticket/30459#comment:10>

Django

unread,
May 15, 2019, 1:26:02 PM5/15/19
to django-...@googlegroups.com
#30459: If a StackedInline has fieldsets with the "collapsed" class, the "Show"
link doesn't work on inline forms added with the "Add another [inline
object]" link
-------------------------------------+-------------------------------------
Reporter: Antonis | Owner: Carlton
Christofides | Gibson
Type: Bug | Status: assigned
Component: contrib.admin | Version: 2.2
Severity: Release blocker | Resolution:
Keywords: | Triage Stage: Ready for
| checkin
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 1
-------------------------------------+-------------------------------------
Changes (by Carlton Gibson):

* needs_tests: 1 => 0
* stage: Accepted => Ready for checkin


--
Ticket URL: <https://code.djangoproject.com/ticket/30459#comment:11>

Django

unread,
May 17, 2019, 2:05:24 AM5/17/19
to django-...@googlegroups.com
#30459: If a StackedInline has fieldsets with the "collapsed" class, the "Show"
link doesn't work on inline forms added with the "Add another [inline
object]" link
-------------------------------------+-------------------------------------
Reporter: Antonis | Owner: Carlton
Christofides | Gibson
Type: Bug | Status: closed
Component: contrib.admin | Version: 2.2
Severity: Release blocker | Resolution: fixed

Keywords: | Triage Stage: Ready for
| checkin
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 1
-------------------------------------+-------------------------------------
Changes (by Mariusz Felisiak <felisiak.mariusz@…>):

* status: assigned => closed
* resolution: => fixed


Comment:

In [changeset:"e286987a27271c8ee7eb6e4d4332b563c4e6094b" e286987a]:
{{{
#!CommitTicketReference repository=""
revision="e286987a27271c8ee7eb6e4d4332b563c4e6094b"
Fixed #30459 -- Delegated hide/show JS toggle to parent div.

Co-authored-by: Carlton Gibson <carlton...@noumenal.es>
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/30459#comment:12>

Django

unread,
May 17, 2019, 2:06:05 AM5/17/19
to django-...@googlegroups.com
#30459: If a StackedInline has fieldsets with the "collapsed" class, the "Show"
link doesn't work on inline forms added with the "Add another [inline
object]" link
-------------------------------------+-------------------------------------
Reporter: Antonis | Owner: Carlton
Christofides | Gibson
Type: Bug | Status: closed
Component: contrib.admin | Version: 2.2

Severity: Release blocker | Resolution: fixed
Keywords: | Triage Stage: Ready for
| checkin
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 1
-------------------------------------+-------------------------------------

Comment (by Mariusz Felisiak <felisiak.mariusz@…>):

In [changeset:"34a357d519a6ff37516c963181af912f776ea80d" 34a357d5]:
{{{
#!CommitTicketReference repository=""
revision="34a357d519a6ff37516c963181af912f776ea80d"
[2.2.x] Fixed #30459 -- Delegated hide/show JS toggle to parent div.

Co-authored-by: Carlton Gibson <carlton...@noumenal.es>

Backport of e286987a27271c8ee7eb6e4d4332b563c4e6094b from master
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/30459#comment:13>

Reply all
Reply to author
Forward
0 new messages