janosh / svelte-toc

Sticky responsive table of contents component
https://janosh.github.io/svelte-toc
MIT License
113 stars 6 forks source link

Issues with highlighting the correct content #50

Open vamshinenu opened 11 months ago

vamshinenu commented 11 months ago

when I was in your web page I was trying to move around, and found out that. when I click on Usage and back on Examples the highlight is still on Usage tables of content. and for another example

when you are on top, try clicking on the bottom line Test Page Navigation it was highlighting on Styling instead.

janosh commented 10 months ago

Unfortunately, that's a known shortcoming of the set_active_heading implementation using activeHeadingScrollOffset to determine which heading is active.

https://github.com/janosh/svelte-toc/blob/532acf0d1b895ffd1b457e54a90fa9c313724baa/src/lib/Toc.svelte#L80-L107

While I think there's no perfect solution here (e.g. "clicking on the bottom line Test Page Navigation it was highlighting on Styling instead" seems unavoidable if headings are nearby) I readily admit this could likely be improved. PRs welcome!