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

Use of hidden="hidden" breaks DjDT when used with bootstrap4 and pureCSS #742

Closed
frgtn opened this issue Aug 31, 2015 · 13 comments · Fixed by cookiecutter/cookiecutter-django#1470
Labels

Comments

@frgtn
Copy link

frgtn commented Aug 31, 2015

django-debug-toolbar uses hidden="hidden" attributes on its HTML elements which are left regardless of element being displayed or not. This causes django-debug-toolbar UI (both handle and main interface) to remain hidden when used together with Bootstrap 4 or PureCSS.

Both Boostrap 4 and PureCSS use:

[hidden] {
  display: none !important;
}

https://github.com/twbs/bootstrap/blob/v4.0.0-alpha/scss/_utilities.scss#L35

The problem is that jQuery .show() does not remove hidden="hidden" attribute but instead sets style="display: block", which is overriden by the above CSS block (See note about !important in http://api.jquery.com/show/)

One approach would be to follow jQuery docs and use .css('style', 'display: block !important'). A better approach would be to use style="display: none" instead of hidden="hidden" which I think is better, since style attribute is also used for setting DjDT handle position.

@tim-schilling
Copy link
Contributor

We are using hidden="hidden" to allow for a content security policy to be enabled as per #330 and #704.

@ssbb
Copy link

ssbb commented Sep 7, 2015

Fixed it for me with this rule:

[hidden][style="display: block;"] { display: block !important; }

@audreyfeldroy
Copy link
Member

@ssbb thanks for the workaround. We're using it for now in cookiecutter-django.

@VidJa
Copy link

VidJa commented Oct 29, 2015

@ssbb, thanks, had this problem when starting with bootstrap4.

@SimonSteinberger
Copy link

Admitted, I don't understand the security policy issue, which is the reason for using the hidden attribute in this way. However, regardless I believe somethings wrong here. The hidden attribute's purpose is to define elements as hidden. I think PureCSS and Twitter Bootstrap got it right. Maybe django_toolbar should revert to using the data attributes if possible. This issue will likely affect more and more people in time. Still, wonderful Django addon 👍 👍

@ssbb: Perfect workaround! 👍

@ssbb
Copy link

ssbb commented Oct 30, 2015

Better to use "contains" instead of equality (because toolbar handle is movable (via style="top: xxx") and if you will move it, you can never see it again :D)

[hidden="hidden"][style*="display: block;"] { display: block !important; }

@aaugustin
Copy link
Contributor

Perhaps we could achieve the desired effect with a djdt-hidden CSS class instead? Is someone interested in trying that and submitting a patch? This sounds better than asking everyone to add hacks to their CSS...

@svetlyak40wt
Copy link
Contributor

BTW, found the same issue, when using Material Design Lite's css.

@aaugustin
Copy link
Contributor

Indeed, I noticed that a few days ago as well.

@nicolastobo
Copy link

Same issue with MDL @aaugustin, did you find out a trick ?

@aaugustin
Copy link
Contributor

4111d93 should fix this.

papousek added a commit to adaptive-learning/proso-apps that referenced this issue Mar 2, 2016
Remove this hack after upgrading of debug toolbar on version > 1.4, see
jazzband/django-debug-toolbar#742.
papousek added a commit to adaptive-learning/proso-apps that referenced this issue Mar 3, 2016
Remove this hack after upgrading of debug toolbar on version > 1.4, see
jazzband/django-debug-toolbar#742.
@maguowei
Copy link

please release a new fix version on pypi. @aaugustin

@aaj
Copy link

aaj commented Jul 4, 2016

Yes please

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