-
Notifications
You must be signed in to change notification settings - Fork 47.3k
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
Replace the header_links plugin with client-side generated anchors. #4165
Conversation
Thank you for your pull request and welcome to our community. We require contributors to sign our Contributor License Agreement, and we don't seem to have you on file. In order for us to review and merge your code, please sign up at https://code.facebook.com/cla - and if you have received this in error or have any questions, please drop us a line at [email protected]. Thanks! |
docs/_layouts/default.html
Outdated
.replace(/\s+/g, '-') | ||
.replace(/[^A-Za-z0-9\-_.]/g, ''); | ||
|
||
elements[i].setAttribute('id', tidyText); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do the anchors actually work, since you're setting the ID after it's rendered? Does the browser correctly scroll down to the anchor when you open a fresh tab and go to a URL with an anchor?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The anchors do work. I did some testing across the various desktop browsers where I added anchors at various points in the loading process. I found that they all hop to IDs added after the DOM is fully loaded, though they differ in how much later in the process they will successfully jump to the anchor. In case you're curious, here's where each of the browsers fared on the test (the browser name is listed where they last successfully jumped to the anchor).
- On DOM Ready (DOMContentLoaded)
- Safari
- Chrome
- Opera
- On Page Fully Loaded (window.onload)
- Firefox
- IE
- After Arbitrary setTimeout
- - none -
In short, we're safe in adding the IDs where we have, at least for all the browsers I tested.
Thank you for signing our Contributor License Agreement. We can now accept your code for this (and any) Facebook open source project. Thanks! |
OK, this is ready for review again. I also included a CSS adjustment that ensures the Sticky header doesn't obscure the heading being anchored to. |
OK so this is fairly old, we redid a lot of the website since then, and there are merge conflicts. @bryanbraun does this PR still make sense and are you still interested in working on it? Or should we just deem it "timed out" and close it. |
Btw this is the oldest open PR in React repo :-) |
@lacker, thanks for following up. I'd like to try rebasing it later this week, and seeing if this kind of change still makes sense with the updated site. I'll let you know what I find by end of day Friday. |
@lacker, I've rebased the PR so it should apply cleanly now. The code is in the same place as it was in the original PR (before the closing body tag) but it can be moved if needed. I did a bit of testing in Chrome and IE9 and haven't found any functional or visual issues. I also ran a |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just a few small comments. Thanks for fixing this up!
@@ -122,6 +122,7 @@ h1, h2, h3, h4, h5, h6 { | |||
.hash-link { | |||
color: $mediumTextColor; | |||
display: none; | |||
padding-left: 8px; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this a UI change or is this just to compensate for something that's happening in that Redcarpet library? If it is a UI change, would you mind posting a before and after screen shot to show what you're changing here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
docs/_layouts/default.html
Outdated
@@ -62,6 +62,36 @@ | |||
|
|||
<div id="fb-root"></div> | |||
<script> | |||
(function() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It seems inconsistent to inline this when things like live_editor.js
are included as separate scripts, what do you think about refactoring this out similar to the other stuff?
I suspect people in the future will be digging through old code and trying to figure out what the heck this bit is doing, so would you mind adding just enough overall comments to explain what it is that this section of code is trying to accomplish?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good call. I've made these updates in 1757114.
Also adds a couple comments, for context.
Ok, that should be all the changes you requested. 👍 |
Thank you! This seems a bit less technical debty, in addition to working better with RSS, since I have a sneaking suspicion that React folks would prefer to write javascript than ruby. |
😮 |
Fixes #4124