Skip to content
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

Anchor links highlight wrong heading in TOC nav #291

Open
PhilReedData opened this issue Oct 14, 2024 · 7 comments
Open

Anchor links highlight wrong heading in TOC nav #291

PhilReedData opened this issue Oct 14, 2024 · 7 comments
Labels
bug Something isn't working

Comments

@PhilReedData
Copy link
Contributor

In my test SEEK docs site, I have some anchor links in the sidebar navigation, for example, from the homepage, expand the 'Assets' sidebar menu and click 'SOPs'. On the next page, the right-side TOC menu has 'Publications' highlighted, which is a different heading to the one selected. The address bar shows the correct URL (in this case, # sops).
image

It works fine with 'Activities' then 'Events'. It does not work with 'General attributes and links' then 'Sharing', which points instead to 'Publishing' on the TOC most of the time. It works fine if you're already on the parent page.
image

(I am trying to reduce the amount of these anchor links and duplicated links.)

I think this is a bug in the recent TOC code. I'm using ETT remote version 3.2.0.

@bedroesb
Copy link
Member

Hello Phil! I agree that we can improve the precision of the scrollspy, but let's say the bootstrap JS I am using for this is not very reliable in general (see also #178 ). With the latest version the precision of scrolling towards a heading got greatly improved, but the scrollspy is still working in the same way when the page would scroll to a heading more in the middle of the page.

Personally I think the anchors should really not be used in the side navigation .. I was getting dizzy navigating to the website with all the scrolling going on haha.

Is there a reason why they are still there? I know I am deflecting the original question, but it seems that the website could get improved easily by having better defined subpages than everything on one page where is linked too from many different places. Also make sure the sidebar is always linking to the exact url, so the sidebar highlighting works.

Also how coes that within assets the user gets linked to General attributes?
image

Sorry I was trying to understand the structure, you can ignore my comments!

@bedroesb
Copy link
Member

To answer specific to your question. I would not want to add official support for anchors in the sidebar. But we can reshape the issue to make sure when people follow from scratch the link: https://docs-testing.seek4science.org/help/user-guide/general-attributes#sops, the correct TOC item is highlighted

@bedroesb
Copy link
Member

Also the fact that the sidebar does not highlight anchor links correctly should be a giveaway that the theme is not made for it!

@PhilReedData
Copy link
Contributor Author

PhilReedData commented Oct 15, 2024

Hi Bert, thanks for this. I've now found a sensible way to remove all the anchor links from this sidebar. For example, the top Samples page now has the 'Browsing samples' links in the page itself, not the sidebar.
The test server will be auto updated with my latest code overnight tonight.
image
Above: Samples. Below: Assets.
image
That should stop most of the surprise scrolling. I still have two pages that appear twice in the menu, but that has nothing to do with the template!

@bedroesb
Copy link
Member

Looks a lot better! I just notice there is a child item with the same name is the parent item, "Samples". You can put pages behind parent collapsables too if needed.

@bedroesb bedroesb changed the title Clicking anchor link in sidebar nav shows the wrong link in toc nav Anchor links highlight wrong heading in TOC nav Oct 15, 2024
@PhilReedData
Copy link
Contributor Author

Indeed. I wasn't sure about this. All of the other parents / sections do not have their own page, they are just collections of pages. Samples is different as there is a page called Samples. To be consistent with the other sections, I kept the two items labelled Samples but that is a bit confusing in a different way, two links with the same name. Perhaps there is a better label for one of them.

@bedroesb bedroesb added the bug Something isn't working label Oct 15, 2024
@PhilReedData
Copy link
Contributor Author

'Samples' and 'Samples introduction' is better.
image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants