Problem/Motivation
The sticky table header on admin/people/permissions The sticky header on the permissions page magically appears in the center of your browser window when scrolling down the page. Attached are some screenshots of the issue once you scroll past the header:


Proposed resolution
Per comment #15:
Change the isNaN() function to (typeof offsetTop === 'number') and trigger the "should be visible" check on Table Header initialization
Remaining tasks
(DONE #18) Review the proposed patch (from #15).
Tested on:
Firefox - 29.0.1
Chrome - 35.0.1916.114
Safari - 7.0.3 (9537.75.14)
User interface changes
Make sure that the table is positioned at the top instead of 'halfway' on the screen when scrolling on the page.
After Patch (comment #15) Screen Shot showing resolution of scrolling issue

| Comment | File | Size | Author |
|---|---|---|---|
| #18 | Screen Shot 2014-06-01 at 10.46.08 AM.jpg | 65.13 KB | JamesGrierson |
| #15 | fix_sticky_table_header-2269129-15.patch | 824 bytes | michaelfavia |
| #8 | sticky_header-2269129-8.patch | 530 bytes | sqndr |
| broken-permissions-table-2.png | 201.42 KB | sqndr | |
| broken-permissions-table-1.png | 209.33 KB | sqndr |
Comments
Comment #1
sqndr commentedComment #2
sqndr commentedThis patch fixes the issue. The main problem is that the header is fixed, but no
topis set for the element. With the patch, a top value is set for the element; making it sticky.Comment #3
sqndr commentedHm. Looking at the issue again. I guess the problem must be in these lines of
tableHeader.js:Line 210:
this.stickyPosition(null, scrollValue('scrollLeft'));This results in the following function getting executed:
Line 172-181
If I set a console.log(offsetTop) inside
if (!isNaN(offsetTop)) {...}, it logsnullto the console every time I scroll. This should not be happening, right? Instead of the previous patch I submitted where I give the top value every time into the function, there's another way of fixing this:this.stickyPosition(undefined, scrollValue('scrollLeft'));When changing the
nullintoundefined, the code doesn't go in theif (!isNaN(offsetTop)) {..}any more. The results in a correct positioned sticky header.In short: I think the problem here is that the
isNaN()returnsfalseforisNaN(null); // false. Changing it to undefined fixed the problem. Here's some more examples:I'm not a Javascript expert, so I'm just sharing my debugging experience here, hoping that someone can come up with a proper solution. ;-)
Comment #4
sqndr commentedHm, I wrote a patch changing the
nullintoundefinedas explained in #3.Comment #5
sqndr commentedComment #6
lewisnymanComment #7
sqndr commentedComment #8
sqndr commentedWrote a new patch to see if it can pass the tests.
Comment #9
Anonymous (not verified) commentedLooks like a slam dunk to me, works for me. Changing to RTBC.
Comment #10
nod_Oh man that's such a wtf. Good catch, no idea null was actually a number :p
Comment #11
sqndr commentedIn my search for the answer I came across this issue on StackOverflow. In case anyone's really interested ;-)
Comment #13
Mitson commentedHi,
I noticed the same problem.
Why to change 'null' to 'undefined'?
This
!isNaN != isNumbercan lead to problems in the future.Is there a problem to use the built-in jquery function 'isNumeric'?
This patch works for me.
Comment #14
lewisnymanComment #15
michaelfavia commentedRan into this myself today. Attached patch simplifies the check. isNaN() is a broken method at its core. What we are really interested in is if the value is updated and its a number. This check does just that.
It also triggers the "should be visible" check on Table Header initialization as i thought maybe it was overlooked as well. If we dont want to correctly display sticky table headers until the actual onScroll event for some reason i can remove the line.
Comment #16
nod_Now that tableheaders are off by default on table I don't care as much about initializing this on page load. If we want to do that It'd make more sense to rip the whole scroll thing apart.
Comment #17
lewisnymanComment #18
JamesGrierson commentedreviewed -
downloaded fix_sticky_table_header-2269129-15.patch
ran git apply -v fix_sticky_table_header-2269129-15.patch in terminal
viewed on page /admin/people/permissions and the sticky header now stays at the top of the window vs. showing up mid page on scroll
Tested on:
Firefox - 29.0.1
Chrome - 35.0.1916.114
Safari - 7.0.3 (9537.75.14)
Comment #19
JamesGrierson commentedAdded after screen shot and noted browser that were tested to the issue summary.
Comment #20
JamesGrierson commentedI also opened the patch and reviewed code. I looked at the changes and they are all within scope and seem reasonable to me to address the issue.
Comment #21
JamesGrierson commentedAdded more detail to the problem/motivation section along with proposed resolution details and performed general cleanup of project information.
Comment #22
sqndr commentedCheck, with the recent changes this still works like a charm! Awesome.
Comment #23
vinmassaro commentedTested and works. Thanks.
Comment #24
alexpottCommitted 625463d and pushed to 8.x. Thanks!