Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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
Add anchors to Markdown headers #2513
Add anchors to Markdown headers #2513
Changes from 11 commits
2a3e56e
d92cf59
778b4d7
427757e
80fedfc
c41e0ef
3fcf660
bc87c7d
3b64e68
b024e59
f813427
ece7d59
b050b15
c9c790f
bfff598
278e0b3
c82185d
a267646
a243dbb
8027b70
dd302c4
3f7d3f7
59f8a4c
3c3308b
ac5beeb
8e52a07
62469c9
5ae0bee
e64aba3
7339f8f
19974fd
e5285fd
File filter
Filter by extension
Conversations
Jump to
There are no files selected for viewing
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.
Hm so this
alreadyScrolled
would prevent scrolling back to the same element when the anchor value changes. But if we somehow changed the hash and then changed it back, I don't believe this will get called / scroll into view. Alternatively if we changed the anchor and changed it back to match the current hash, it wouldn't scroll. Not sure how many scrolling use cases we want to get into with all this scrolling business. Could be something we refine as part of a future task but defer to @asaini.I'm not sure if this would also prevent us from scrolling to multiple elements?
alreadyScrolled
looks to be locally defined so each tag with an anchor would get it's own.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.
Ok, I think I fixed this by just passing the anchor as the header's
id
. The dynamic scrolling handles scrolling on render, and after that, the browser handles everything else for us (clicking on a#link
, manually changing the url, etc.)createHeadingWithAnchor()
is only called once to initializeHeaderWithAnchor
, so all instances of<HeaderWithAnchor>
will use that variable stored in the closure. You're right though, it's confusing, I'll just make it global.