Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Collapsed fieldset flickers when StackedInline is expanded #129

Closed
Talkless opened this issue Aug 29, 2014 · 11 comments
Closed

Collapsed fieldset flickers when StackedInline is expanded #129

Talkless opened this issue Aug 29, 2014 · 11 comments

Comments

@Talkless
Copy link
Contributor

Using:
Python 3.4.1
Django 1.6.6
django-admin-bootstrapped 1.6.8

Test foo.models.py:

from django.db import models

class A(models.Model):
    title = models.CharField(max_length=100)
    notes = models.TextField(null=True)

    def __str__(self):
        return self.title

class ABRelation(models.Model):
    position = models.PositiveSmallIntegerField()
    a = models.ForeignKey(A)
    b = models.ForeignKey("B")

    class Meta:
        ordering = ("position",)

class B(models.Model):
    title = models.CharField(max_length=100)
    a = models.ManyToManyField(A, through=ABRelation)

    def __str__(self):
        return self.title

Test foo.admin.py:

from django.contrib import admin
from foo.models import A, B, ABRelation
from django_admin_bootstrapped.admin.models import SortableInline

class AAdmin(admin.ModelAdmin):
    model = A
    list_display = ("pk", "title")
    fields = ("title",)

class ABRelationInlineAdmin(SortableInline, admin.StackedInline):
    model = ABRelation
    list_display = ("pk", "title")
    readonly_fields = ("a_title", "a_notes")
    fieldsets = (
                (None, {
                        "fields" : ("position", "a")
                }),
                ("More info", {
                        "classes" : ("collapse",),
                        "fields" : ("a_title", "a_notes")
                })
    )

    def a_title(self, obj):
        return obj.a.title

    def a_notes(self, obj):
        return obj.a.notes


class BAdmin(admin.ModelAdmin):
    model = B
    list_display = ("pk", "title")
    fields = ("title",)
    inlines = (ABRelationInlineAdmin,)

admin.site.register(A, AAdmin)
admin.site.register(B, BAdmin)

To reproduce:

  1. Open change/create view for B model.
  2. Collapse first StackedInline #1 (ab relation).
  3. Expand first StackedInline, "More info" flickers of a moment - it gets expanded, then goes to collapsed state.

Repead 3-2-3-2.. until eye caches that in fact "More info" with "A title" is expanded, visible for a spit second. The more fields are in fieldset, the more it's noticeable.

Same with Kubuntu 14.04 Firefox 31 and Windows 7 (VirtualBox) Chrome, IE10, Opera, ...

@xrmx
Copy link
Contributor

xrmx commented Aug 29, 2014

Is this a regression in 1.6.8 vs 1.6.7? Btw i can't see any flickering on my ~4.5 years linux old laptop in the test applications shipped in the repository.

UPDATE: collapse.js could use some cleanup though

@Talkless
Copy link
Contributor Author

Just checked in 1.6.7 - StackedInline does not even collapse there. 1.6.8 is kinda better, but something a little strange with inner fieldset.

I've uploaded video:
https://www.youtube.com/watch?v=xESs-ncwNFc

You can see in some frames that "More info" fieldset gets expanded, with A title: visible.

@xrmx
Copy link
Contributor

xrmx commented Aug 29, 2014

Thanks for the video, collapse.js is the django one though. Does adding display: block to a.collapsed help?

@Talkless
Copy link
Contributor Author

Nope.

@xrmx
Copy link
Contributor

xrmx commented Sep 10, 2014

So it turns out this is the bootstrap collapse stuff, according to [1] performance may vary depending on the html. Also it looks to me that collapsible fieldsets inside empty inlines are collapsed together and not just the one where i clicked.

[1] http://stackoverflow.com/questions/24166588/bootstrap-3-accordion-effect-on-table-is-very-slow

@Talkless
Copy link
Contributor Author

Yes, fieldsets expands together for brief time and collapses. If there would be some kind more "precise", limiting selectors, maybe only parent one would be expanded/collapsed then.

@xrmx
Copy link
Contributor

xrmx commented Sep 16, 2014

That could be the cause of the slowness you see, we're doing a lot more work than the one we need to.

xrmx added a commit to xrmx/django-admin-bootstrapped that referenced this issue Sep 16, 2014
Add a prefix to each nested fieldsets so that only one clicked
gets the collapse event and not every collapsed fieldsets of the
same inline formset.

As discussed in django-admin-bootstrapped#129
@xrmx
Copy link
Contributor

xrmx commented Sep 16, 2014

Any chance you can try latest master please? i've fixed the multiple opening of collapsible fields, hopefully it helps.

@Talkless
Copy link
Contributor Author

Hmm, I do not see significant changes. I still get effect as in posted video. New "stacked_prefix" does not apprear for some reason.
stacked_prefix_missing

@xrmx
Copy link
Contributor

xrmx commented Nov 19, 2014

@Talkless I took another stab at this, indeed this is not working at all. Unfortunately i really don't see why stacked_prefix is not passed down to includes/fieldset.html

brandoncazander pushed a commit to brandoncazander/django-admin-bootstrapped that referenced this issue Nov 25, 2014
@xrmx xrmx closed this as completed in 6f097c0 Nov 26, 2014
@xrmx
Copy link
Contributor

xrmx commented Nov 26, 2014

@Talkless Please give it a try to latest master as @brandoncazander fixed it!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants