# Header sometimes not sticking to the top of the page

**URL:** https://meta.discourse.org/t/header-sometimes-not-sticking-to-the-top-of-the-page/24469
**Category:** Bug
**Created:** [27.Январь.2015 00:27:20 UTC](https://meta.discourse.org/t/header-sometimes-not-sticking-to-the-top-of-the-page/24469 "2015-01-27T00:27:20Z")
**Posts on this page:** 12
**Page:** 1

<div class="post-metadata">

### Author: ![mcwumbly](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/mcwumbly/32/103861_2.png) [@mcwumbly](https://meta.discourse.org/u/mcwumbly)
#### Post date: [27.Январь.2015 00:27:20 UTC](https://meta.discourse.org/t/header-sometimes-not-sticking-to-the-top-of-the-page/24469/1 "2015-01-27T00:27:20Z")

</div>

Continuing the discussion from [The end of Clown Vomit, or, simplified category styles](https://meta.discourse.org/t/the-end-of-clown-vomit-or-simplified-category-styles/24249/109):

> [@cpradio](#):
>
> Why is the header no longer sticking to the top of the page when scrolling through a topic?

I saw this once today too… not sure how to reproduce though…

---

<div class="post-metadata">

### Author: ![cpradio](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/cpradio/32/4970_2.png) [@cpradio](https://meta.discourse.org/u/cpradio)
#### Post date: [27.Январь.2015 00:28:07 UTC](https://meta.discourse.org/t/header-sometimes-not-sticking-to-the-top-of-the-page/24469/2 "2015-01-27T00:28:07Z")

</div>

Not sure, but its happening to me right now 😉

Not sure what (if anything) I did special… drats. Hard refresh fixed it.

---

<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: [27.Январь.2015 01:02:39 UTC](https://meta.discourse.org/t/header-sometimes-not-sticking-to-the-top-of-the-page/24469/3 "2015-01-27T01:02:39Z")

</div>

Confirmed here … lets see if I can repro

---

<div class="post-metadata">

### Author: ![codinghorror](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/codinghorror/32/110067_2.png) [@codinghorror](https://meta.discourse.org/u/codinghorror)
#### Post date: [27.Январь.2015 01:11:50 UTC](https://meta.discourse.org/t/header-sometimes-not-sticking-to-the-top-of-the-page/24469/4 "2015-01-27T01:11:50Z")

</div>

Yeah I get this now too, it’s always on navigation to another topic via Suggested Topics. Very odd.

My _guess_ is we have invalid HTML in there somewhere, somehow?

---

<div class="post-metadata">

### Author: ![mcwumbly](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/mcwumbly/32/103861_2.png) [@mcwumbly](https://meta.discourse.org/u/mcwumbly)
#### Post date: [27.Январь.2015 01:21:29 UTC](https://meta.discourse.org/t/header-sometimes-not-sticking-to-the-top-of-the-page/24469/5 "2015-01-27T01:21:29Z")

</div>

Happening on mobile too.

---

<div class="post-metadata">

### Author: ![cpradio](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/cpradio/32/4970_2.png) [@cpradio](https://meta.discourse.org/u/cpradio)
#### Post date: [27.Январь.2015 01:26:47 UTC](https://meta.discourse.org/t/header-sometimes-not-sticking-to-the-top-of-the-page/24469/6 "2015-01-27T01:26:47Z")

</div>

> [@codinghorror](#):
>
> Yeah I get this now too, it’s always on navigation to another topic via Suggested Topics. Very odd.

Yes, that may be it. I’ve been trying a dozen things since I originally got it to happen and I forgot that I was primarily browsing from Suggested Topics initially (I surprisingly, don’t do that very often, just when I’m in a hurry).

---

<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: [27.Январь.2015 02:56:52 UTC](https://meta.discourse.org/t/header-sometimes-not-sticking-to-the-top-of-the-page/24469/7 "2015-01-27T02:56:52Z")

</div>

I just reverted a change with categories that may have been causing it, oddly enough code looks good, but this could be a jQuery bug or something.

Very hard to debug cause I can not get a local repro:

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

cc @zogstrip

---

<div class="post-metadata">

### Author: ![Mittineague](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/mittineague/32/114259_2.png) [@Mittineague](https://meta.discourse.org/u/Mittineague)
#### Post date: [27.Январь.2015 04:31:42 UTC](https://meta.discourse.org/t/header-sometimes-not-sticking-to-the-top-of-the-page/24469/8 "2015-01-27T04:31:42Z")

</div>

I did experience the non-sticky header earlier today but whatever you did seems to have fixed it, unless it’s just coincidence. Darn no-repo sporadic bugs are the bane!

---

<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: [27.Январь.2015 04:38:50 UTC](https://meta.discourse.org/t/header-sometimes-not-sticking-to-the-top-of-the-page/24469/9 "2015-01-27T04:38:50Z")

</div>

It was happening to me quite consistently in production (but not in dev) before I hacked out that code.

---

<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: [28.Январь.2015 00:25:17 UTC](https://meta.discourse.org/t/header-sometimes-not-sticking-to-the-top-of-the-page/24469/10 "2015-01-28T00:25:17Z")

</div>

Like @sam I could not reproduce locally… I changed the regexp and deployed the change here. Haven’t heard a single complaint since, so I’m guessing it’s working fine now 🐋

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

---

<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: [28.Январь.2015 01:20:37 UTC](https://meta.discourse.org/t/header-sometimes-not-sticking-to-the-top-of-the-page/24469/11 "2015-01-28T01:20:37Z")

</div>

The reason it didn’t work is because using a `\b` in a “character class” is a “backspace” and `[^\b]` is equivalent to saying:

```
Match any character that is NOT the backspace character (ASCII 8)

```

Original regex for reference: `\bcategory-[^\b]+`

---

<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: [28.Январь.2015 08:29:16 UTC](https://meta.discourse.org/t/header-sometimes-not-sticking-to-the-top-of-the-page/24469/12 "2015-01-28T08:29:16Z")

</div>


