A user, Fma965, reported that category-specific CSS (targeting body[class^="category-documentation"]) fails to apply dynamically when navigating between categories on their Discourse site — elements remain visible until a full page refresh (F5). awesomerobot initially suspected the Air Theme’s Loading Slider component, but disabling it didn’t help. Further investigation revealed a core bug: category classes like category-documentation-21 linger on the <body> tag during page transitions instead of being properly removed or replaced awesomerobot. This was confirmed as a server-side issue originating from application_helper.rbawesomerobot. A temporary workaround using api.onPageChange() with inline <style> tags was implemented by Fma965. The core bug was later fixed in commit 333c58dawesomerobot. However, even after the fix, the CSS still didn’t apply correctly because class^= only matches classes at the start of the class list — but category classes aren’t always first. Switching to class*= (which matches anywhere in the class list) resolved the issue awesomerobot. Fma965 confirmed the combination of the core fix and updated CSS selector now works as expected.
This works great for hiding loads of elements on a “documentation” category (yes i know a docs plugin exists, i find the native layout better though) my issue is when i click from say “Ford” to “Documentation” the CSS doesn’t refresh and therefore my stuff is not hidden unless i refresh the whole page with f5 / ctrl + R
Is there something i am missing to allow this to work?
The same applies the other way around also
You can visit any category on https://community.cyanlabs.net and then go to documentation and will see the hidden CSS elements still show.
It looks like you’re using the Air Theme, which includes the Discourse Loading Slider theme component.
If you disable that component from admin > customize > themes > components, and then try again… does that change anything? sometimes that component can cause an issue where classes linger between pages until you refresh.
Ah ok… taking a closer look, it seems like there’s a dynamic class getting added by a theme to the body tag category-documentation-21 and category-ford-5 for example… on page transitions those classes don’t seem to be removed properly.
We’ll update this topic when it’s fixed (or something else related). If you change your tracking level to “watching” in the dropdown at the bottom of the topic, you’ll get notified of new posts.