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

TOC not updating correctly in Chrome #1981

Open
BartJanvanRossum opened this issue Dec 30, 2021 · 16 comments
Open

TOC not updating correctly in Chrome #1981

BartJanvanRossum opened this issue Dec 30, 2021 · 16 comments
Labels
bug an unexpected problem or unintended behavior front end 🌷 General HTML, CSS, and JS issues

Comments

@BartJanvanRossum
Copy link

The content menu is not unfolding as expected. More specifically, selecting the bottom item in the content list unfolds the item above and selects that item and within the item the last subitem. For https://github.com/Biometris/statgenSTA/tree/develop:

image

The page does still move to the correct location and manually scrolling further down, even just one line, will unfold the correct item in the content menu:

image

I tested this with both the CRAN version and the main github branch of pkgdown with identical results. Also there is no difference whether bootstrap 5 is used or not.

@hadley

This comment was marked as outdated.

@BartJanvanRossum

This comment was marked as outdated.

@hadley

This comment was marked as outdated.

@BartJanvanRossum

This comment was marked as outdated.

@hadley

This comment was marked as outdated.

@BartJanvanRossum

This comment was marked as outdated.

@hadley

This comment was marked as outdated.

@BartJanvanRossum

This comment was marked as outdated.

@hadley

This comment was marked as outdated.

@hadley hadley added bug an unexpected problem or unintended behavior front end 🌷 General HTML, CSS, and JS issues labels May 31, 2022
@hadley
Copy link
Member

hadley commented Apr 12, 2024

Even more minimal reprex: visit https://bartjanvanrossum.github.io/statgenSTA/articles/statgenSTA.html#extracting-model-results in chrome. "Model reports" is highlighted instead of "Extracting model results"

Probably something to do with scroll-padding.

@hadley
Copy link
Member

hadley commented Apr 19, 2024

But the problem doesn't seem to occur on https://pkgdown.r-lib.org/articles/customise.html#sidebar

@hadley hadley changed the title Content section not unfolding correctly TOC not updating correctly in Chrome Apr 19, 2024
@BartJanvanRossum
Copy link
Author

The difference might be that "Extracting model results" is the last section in the TOC. In {pkgdown} the sidebar section is somewhere in the middle of the TOC. In {statgenSTA} highlighting works fine when clicking e.g. "Creating a TD object", a section with subsections higher up in the TOC.

@hadley
Copy link
Member

hadley commented Apr 22, 2024

Hmmmm:

But I think those are a case I understand — there's not enough height in the final section to scroll either the PR previews or the conclusions headings to the top of the page so which heading it shows as active is underspecified. One way to fix that would be to add adding padding to the bottom of the page so that they can be scolled.

But I don't think that's what's happening on your page because Extracting model results is a long section, and there's definitely enough room to scroll it to the top. And even for references, which isn't quite tall enough to scroll to the top, there's still only one heading visible on the page.

@hadley
Copy link
Member

hadley commented Apr 22, 2024

One possible issue to look into is that I should now be supplying rootMargin instead of offset: https://getbootstrap.com/docs/5.3/components/scrollspy/#options — hmmmm, but we're still only using 5.1

@hadley
Copy link
Member

hadley commented Apr 22, 2024

Carefully scrolling around in chrome makes me think it is an offset problem. If I jump to https://bartjanvanrossum.github.io/statgenSTA/articles/statgenSTA.html#modeling and then scroll down even slightly, it does highlight the correct heading. Currently I'm setting offset: $("nav.navbar").outerHeight() + 1, and I do wonder where that + 1 is coming from.

@hadley
Copy link
Member

hadley commented Apr 22, 2024

I think this is beyond my ability to debug — I think someone with deeper knowledge of js will need to read the source code of the scrollspy plugin to figure out what's going wrong 😞

(It's also possibly/probably some interaction with https://github.com/WickyNilliams/headroom.js)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug an unexpected problem or unintended behavior front end 🌷 General HTML, CSS, and JS issues
Projects
None yet
Development

No branches or pull requests

2 participants