Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

fix: improve underlining in "On this page"#1312

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Open
zqianem wants to merge2 commits intosveltejs:main
base:main
Choose a base branch
Loading
fromzqianem:fix-anchor-link-update

Conversation

zqianem
Copy link
Contributor

This ensures that the anchor that is clicked is always the one that gets underlined, even if just scrolling to that heading would underline a different anchor.

A good test page for thishttps://svelte.dev/docs/kit/introduction; set the browser window size to 1200x1200 and try to click on "What is SvelteKit" in the right sidebar.

Before submitting the PR, please make sure you do the following

  • It's really useful if your PR references an issue where it is discussed ahead of time.
  • Prefix your PR title withfeat:,fix:,chore:, ordocs:.
  • This message body should clearly illustrate what problems it solves.

This ensures that the anchor that is clicked is always the one that getsunderlined, even if just scrolling to that heading would underline adifferent anchor.Using `onhashchange` alone instead of adding `onclick`s to each anchoris not sufficient because it's possible to click on an anchor thatalready has its hash in the URL but has been scrolled away from.
@vercelVercel
Copy link

vercelbot commentedApr 18, 2025

@zqianem is attempting to deploy a commit to theSvelte Team onVercel.

A member of the Team first needs toauthorize it.

@vercelVercel
Copy link

vercelbot commentedApr 20, 2025
edited
Loading

The latest updates on your projects. Learn more aboutVercel for Git ↗︎

NameStatusPreviewUpdated (UTC)
svelte-dev✅ Ready (Inspect)Visit PreviewApr 20, 2025 2:54pm

@zqianem
Copy link
ContributorAuthor

Did some more testing on this and the results are actually browser-dependent based on the relative timings of thehashchange andscroll events. The bad behavior is consistent on Firefox, but doesn't happen most (but not all!) of the time on Chromium.

Even so, there is still a flash of underlining on the wrong anchor before the one clicked on is underlined, and the wrong anchor will always be underlined if loading the page from a link with an anchor (e.g.current vs.this PR).

Either way, this PR unifies and fixes the behavior — the anchor link that is clicked is always the one underlined.

Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers
No reviews
Assignees
No one assigned
Labels
None yet
Projects
None yet
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

1 participant
@zqianem

[8]ページ先頭

©2009-2025 Movatter.jp