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

Incorrect highlighting of active navigation category #660

Closed
aoles opened this issue May 9, 2018 · 4 comments
Closed

Incorrect highlighting of active navigation category #660

aoles opened this issue May 9, 2018 · 4 comments
Labels
bug an unexpected problem or unintended behavior front end 🌷 General HTML, CSS, and JS issues
Milestone

Comments

@aoles
Copy link
Contributor

aoles commented May 9, 2018

The highlighting of active navigation category on the top navbar at https://giscience.github.io/openrouteservice-r doesn't work for me as expected. In particular, when viewing the vignette "Get started" doesn't get highlighted, while when browsing the man pages both "Reference" and "Home" are set to active. Observed under pkgdown 1.0.0.9000.

@hadley hadley added bug an unexpected problem or unintended behavior misc labels May 22, 2018
@hadley
Copy link
Member

hadley commented May 22, 2018

Hmmmmm, I wonder why I don't see this in (e.g.) http://testthat.r-lib.org/news/index.html

@hadley hadley added front end 🌷 General HTML, CSS, and JS issues and removed misc labels May 22, 2018
@aoles
Copy link
Contributor Author

aoles commented May 23, 2018

Thanks @hadley! This minimal pkg reproduces the described behavior illustrated in the screens below.

Some observations:

  • The missing highlighting appears to be related to the presence of the leaflet widget. Removing it from the vignette and recreating the website restores the highlighting of "Get started". This seems to be a general html widget problem not specific to leaflet, as I get he same behavior with DT::datatable(cars). EDIT: This appears to have been fixed recently in the development version of pkgdown on GitHub.

  • The 🏠 icon remains to be always "on" unless the vignette containing a html widget is displayed, then the highlighting doesn't seem to work at all. EDIT: Still an issue in devel..

image

@jayhesselberth
Copy link
Collaborator

jayhesselberth commented May 23, 2018

Rendered site: https://affectionate-edison-98885b.netlify.com/index.html

Home icon has sticky highlight behavior here, but doesn't on other sites (e.g. http://pkgdown.r-lib.org)

Edit: actually it seems stochastic, may just be a browser session issue.

@hadley
Copy link
Member

hadley commented May 23, 2018

There's definitely a bug in the logic in the js function — rather than highlighting all nav sections that match, we need to highlight the one nav that has the longest match. I see this (for example) when rendering the site locally.

@hadley hadley added this to the pkgdown 1.1.0 milestone May 29, 2018
hadley added a commit that referenced this issue Jun 1, 2018
Mark a single tab as active, by looking for the longest match to the path components. If there are multiple matches with equal length, the left-most will be highlighted.

Fixes #660
hadley added a commit that referenced this issue Jun 1, 2018
Mark a single tab as active, by looking for the longest match to the path components. If there are multiple matches with equal length, the left-most will be highlighted.

Fixes #660
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

3 participants