# CSS admin-contents reloaded

**URL:** https://meta.discourse.org/t/css-admin-contents-reloaded/25480
**Category:** Feature
**Created:** [February 21, 2015, 12:15pm UTC](https://meta.discourse.org/t/css-admin-contents-reloaded/25480 "2015-02-21T12:15:57Z")
**Posts on this page:** 20
**Page:** 1

<div class="post-metadata">

### Author: ![JSey](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/jsey/32/3540_2.png) [@JSey](https://meta.discourse.org/u/JSey)
#### Post date: [February 21, 2015, 12:15pm UTC](https://meta.discourse.org/t/css-admin-contents-reloaded/25480/1 "2015-02-21T12:15:57Z")

</div>

Continuing the discussion from [CSS Clearfix for `admin-contents`](https://meta.discourse.org/t/css-clearfix-for-admin-contents/25424/9):

> [@CSS Clearfix for \`admin-contents\`](https://meta.discourse.org/t/css-clearfix-for-admin-contents/25424/9):
>
> I just pushed a fix that will **automagically** disable custom stylesheets when you’re entering the `/admin` section and enable them back when you’re leaving it 💐

I appreciate the idea, but (risking to sound nit-picky) dislike the result for my site: if you have HTML additions which rely on styles which now become automatically disabled, you end up with garbled admin pages - could this become an optional setting (I wouldn’t mind if it defaulted to “off” for the discussed security reasons)? The alternative looks a bit appalling to me, to put all the styles for the HTML customizations as inline CSS…

---

<div class="post-metadata">

### Author: ![zogstrip](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/zogstrip/32/512781_2.png) [@zogstrip](https://meta.discourse.org/u/zogstrip)
#### Post date: [February 21, 2015, 7:08pm UTC](https://meta.discourse.org/t/css-admin-contents-reloaded/25480/2 "2015-02-21T19:08:56Z")

</div>

What kind of customizations have you made to the admin section?

---

<div class="post-metadata">

### Author: ![JSey](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/jsey/32/3540_2.png) [@JSey](https://meta.discourse.org/u/JSey)
#### Post date: [February 21, 2015, 7:12pm UTC](https://meta.discourse.org/t/css-admin-contents-reloaded/25480/3 "2015-02-21T19:12:07Z")

</div>

None specifically for the admin section, I have some 50+ lines of HTML living in Customize-\>CSS/HTML-\>Header; and without the corresponding CSS, this leads to:  
 ![](https://global.discourse-cdn.com/meta/original/3X/7/5/75732fb96d52909031d520d522284c6bf9835f98.png)  
instead of  
 ![](https://global.discourse-cdn.com/meta/original/3X/1/5/1598fa517e8ceccd3647b6be19bbfb5ee175f49e.png) + ![](https://global.discourse-cdn.com/meta/original/3X/e/6/e6c1ee9d2d4f1e96da49d44adc188376b7f7bd1c.png)  
as it was before.

---

<div class="post-metadata">

### Author: ![thangngoc89](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/thangngoc89/32/115436_2.png) [@thangngoc89](https://meta.discourse.org/u/thangngoc89)
#### Post date: [February 21, 2015, 7:13pm UTC](https://meta.discourse.org/t/css-admin-contents-reloaded/25480/4 "2015-02-21T19:13:10Z")

</div>

I think a F5 you clean every custom CSS in admin section

---

<div class="post-metadata">

### Author: ![DeanMarkTaylor](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/deanmarktaylor/32/102462_2.png) [@DeanMarkTaylor](https://meta.discourse.org/u/DeanMarkTaylor)
#### Post date: [February 21, 2015, 7:16pm UTC](https://meta.discourse.org/t/css-admin-contents-reloaded/25480/5 "2015-02-21T19:16:01Z")

</div>

Just to re-iterate what was said to @zogstrip via PM:

I have this problem in admin too.

Directly visiting `/admin` includes the `Header` section from added via `CSS/HTML` \> `Header`.

Now that the CSS is not loaded in `/admin` the custom HTML added via Header is unstyled and looks bad.

---

<div class="post-metadata">

### Author: ![JSey](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/jsey/32/3540_2.png) [@JSey](https://meta.discourse.org/u/JSey)
#### Post date: [February 21, 2015, 7:17pm UTC](https://meta.discourse.org/t/css-admin-contents-reloaded/25480/6 "2015-02-21T19:17:12Z")

</div>

The culprit here is not CSS, that’s properly deactivated. But I have also custom HTML headers which aren’t. Either, Discourse should disable both when I enter admin, or this should be an option: disable CSS when entering admin.

\*sigh\* Now Dean was faster…

---

<div class="post-metadata">

### Author: ![zogstrip](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/zogstrip/32/512781_2.png) [@zogstrip](https://meta.discourse.org/u/zogstrip)
#### Post date: [February 21, 2015, 7:24pm UTC](https://meta.discourse.org/t/css-admin-contents-reloaded/25480/7 "2015-02-21T19:24:08Z")

</div>

I understand, so the bug is that we are **only** disabling custom CSS and not all the customizations…

---

<div class="post-metadata">

### Author: ![DeanMarkTaylor](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/deanmarktaylor/32/102462_2.png) [@DeanMarkTaylor](https://meta.discourse.org/u/DeanMarkTaylor)
#### Post date: [February 21, 2015, 7:25pm UTC](https://meta.discourse.org/t/css-admin-contents-reloaded/25480/8 "2015-02-21T19:25:28Z")

</div>

It seems reasonable to to require admin additions to be done via plugins.

I would like the possibility of user code additions in admin - but you can’t have every thing.

---

<div class="post-metadata">

### Author: ![zogstrip](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/zogstrip/32/512781_2.png) [@zogstrip](https://meta.discourse.org/u/zogstrip)
#### Post date: [February 21, 2015, 7:28pm UTC](https://meta.discourse.org/t/css-admin-contents-reloaded/25480/9 "2015-02-21T19:28:47Z")

</div>

> [@DeanMarkTaylor](#):
>
> I would like the possibility of user code additions in admin - but you can’t have every thing.

Yeah, it’s a balance between ease of extensibility and users making mistakes that are hard to recover from.

---

<div class="post-metadata">

### Author: ![elberet](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/elberet/32/122404_2.png) [@elberet](https://meta.discourse.org/u/elberet)
#### Post date: [February 22, 2015, 1:05am UTC](https://meta.discourse.org/t/css-admin-contents-reloaded/25480/10 "2015-02-22T01:05:22Z")

</div>

To be honest, I think this feature - disabling loaded and working customizations when entering `/admin` - is misguided.

If all you want to do is save yourself from boneheaded hosting customers, by all means add a site setting that turns all the links and buttons into the admin interface into real links that reload the entire page without any customizations and enable that setting by default for your hosted Discourse instances

Just leave those of us who can find a clue without immediately yelling at their paid support alone; please?

---

<div class="post-metadata">

### Author: ![riking](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/riking/32/170938_2.png) [@riking](https://meta.discourse.org/u/riking)
#### Post date: [February 22, 2015, 9:37am UTC](https://meta.discourse.org/t/css-admin-contents-reloaded/25480/11 "2015-02-22T09:37:06Z")

</div>

Let’s try an experiment.

Put this into your `</head>` customization:

```
<style>body { display: none !important; }</style>

```

Enable, save, and close all other forum tabs.

How do you recover?

1. `./launcher enter app` + rails console, which may not be available to every admin of your site (as in, the ones that do have access are asleep).
2. Use the inspector to delete the CSS rules.

Okay. Now let’s change that bad CSS into bad javascript that causes all pages to not load…

---

<div class="post-metadata">

### Author: ![elberet](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/elberet/32/122404_2.png) [@elberet](https://meta.discourse.org/u/elberet)
#### Post date: [February 22, 2015, 10:19am UTC](https://meta.discourse.org/t/css-admin-contents-reloaded/25480/12 "2015-02-22T10:19:32Z")

</div>

What? No!

1. Open a new tab, type in `https://my.forum.org/admin`, fix the customization, done.

And I _just tried exactly that_.

![](https://global.discourse-cdn.com/meta/original/3X/f/a/fa2f40e0f06def0127989e51c9cca77b77f5f2e8.png)

This is my customization _right now_, yet `/admin` is perfectly usable.

---

<div class="post-metadata">

### Author: ![riking](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/riking/32/170938_2.png) [@riking](https://meta.discourse.org/u/riking)
#### Post date: [February 22, 2015, 10:32am UTC](https://meta.discourse.org/t/css-admin-contents-reloaded/25480/13 "2015-02-22T10:32:20Z")

</div>

Oops, I think there was a part of that post that I thought but didn’t type… or I could have just been wrong.

---

<div class="post-metadata">

### Author: ![JSey](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/jsey/32/3540_2.png) [@JSey](https://meta.discourse.org/u/JSey)
#### Post date: [February 22, 2015, 5:05pm UTC](https://meta.discourse.org/t/css-admin-contents-reloaded/25480/14 "2015-02-22T17:05:31Z")

</div>

> [@riking](#):
>
> Okay. Now let’s change that bad CSS into bad javascript that causes all pages to not load…

Agreed - for my case, a completely un-customized admin section would work! It’s the combination of no-CSS+HEAD-customizations that breaks things. I don’t know @elberet’s thoughts on this - but I am used to non-customized admin sections from other software, too. I cannot really imagine a use case where one would need such a thing - but as usual: YMMV…

---

<div class="post-metadata">

### Author: ![chapel](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/chapel/32/122414_2.png) [@chapel](https://meta.discourse.org/u/chapel)
#### Post date: [February 22, 2015, 10:19pm UTC](https://meta.discourse.org/t/css-admin-contents-reloaded/25480/15 "2015-02-22T22:19:14Z")

</div>

And if they did need it, they would need to install it using a plugin. So it is harder to mess up their install, and is definitely their fault if they do.

---

<div class="post-metadata">

### Author: ![JSey](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/jsey/32/3540_2.png) [@JSey](https://meta.discourse.org/u/JSey)
#### Post date: [February 23, 2015, 6:05pm UTC](https://meta.discourse.org/t/css-admin-contents-reloaded/25480/16 "2015-02-23T18:05:14Z")

</div>

Any thoughts on this issue? We’re [not alone](https://meta.discourse.org/t/best-way-to-customize-the-header/13368/19) with it; and I do think disabling both CSS and HTML header/footers would be the least confusing option. To make Dean happier, this could also be configurable… defaulting to off, and a warning sign in red and blink beside it that you lose all support if you click it… 😉

---

<div class="post-metadata">

### Author: ![elberet](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/elberet/32/122404_2.png) [@elberet](https://meta.discourse.org/u/elberet)
#### Post date: [February 23, 2015, 6:49pm UTC](https://meta.discourse.org/t/css-admin-contents-reloaded/25480/17 "2015-02-23T18:49:50Z")

</div>

I still think that this entire debate is misguided and that trying to remove customizations from the initialized app when entering `/admin` is a genuine Bad Idea™.

For example…

We’re telling people to stick JavaScript snippets into their customizations that monkey patch stuff in the Ember app, and removing and re-adding such a JS snippet when entering `/admin` and subsequently coming back to the frontend would run the code again. It should be obvious that this may have unwanted effects. The logical conclusion, then, is to require that JS in customizations is wrapped in a special function call so it doesn’t get executed twice…

…and now a core feature, customizing the look of Discourse, has become an order of magnitude more complex because _some dude_ got confused when `forum.com/admin` looked different than `forum.com` → “Admin”. 😱 ![](https://global.discourse-cdn.com/meta/original/3X/0/3/03590d98a359a447ce7713c78201cdb8a8cfdb6b.gif)

---

<div class="post-metadata">

### Author: ![JSey](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/jsey/32/3540_2.png) [@JSey](https://meta.discourse.org/u/JSey)
#### Post date: [March 2, 2015, 8:00pm UTC](https://meta.discourse.org/t/css-admin-contents-reloaded/25480/18 "2015-03-02T20:00:33Z")

</div>

Is there any news on this issue? The question keeps [re-surfacing](https://meta.discourse.org/t/the-customized-css-does-not-take-effect-on-admin-pages/25876), so we would need a clarification in the admin section, plus the head customizations are just as _dangerous_ as CSS, try this one:

```JS
<script>$("body").css("display","none")</script>

```

---

<div class="post-metadata">

### Author: ![sam](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/sam/32/102149_2.png) [@sam](https://meta.discourse.org/u/sam)
#### Post date: [March 2, 2015, 9:15pm UTC](https://meta.discourse.org/t/css-admin-contents-reloaded/25480/19 "2015-03-02T21:15:00Z")

</div>

Yeah … this whole change is just causing too much confusion, we should revert to the old way we did this.

Apply everywhere, remove if you **refresh** admin.

---

<div class="post-metadata">

### Author: ![zogstrip](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/zogstrip/32/512781_2.png) [@zogstrip](https://meta.discourse.org/u/zogstrip)
#### Post date: [March 2, 2015, 10:41pm UTC](https://meta.discourse.org/t/css-admin-contents-reloaded/25480/20 "2015-03-02T22:41:11Z")

</div>

Here’s the fix 🐘

[https://github.com/discourse/discourse/commit/1b2381d5a03e69859617d2be537091730a9a1282](https://github.com/discourse/discourse/commit/1b2381d5a03e69859617d2be537091730a9a1282)

[Next page](https://meta.discourse.org/t/css-admin-contents-reloaded/25480.md?page=2)
