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

fix(modern-template): nav & toc active state breaks with external urls #9038

Merged
merged 3 commits into from
Aug 3, 2023

Conversation

Lulalaby
Copy link
Contributor

@Lulalaby Lulalaby commented Aug 2, 2023

The current problem

When having an external url defined in the toc.yml, the active state toggler sets all external links & the current page as active

Screenshots

invalid active state

Proposed Solution

By checking whether the items hostname or port differs from window.location, we can set the active state correctly.

Screenshots

correct active state

@Lulalaby Lulalaby force-pushed the fix/nav-toc-active-state branch from 310d471 to d1dac25 Compare August 2, 2023 14:22
@Lulalaby Lulalaby force-pushed the fix/nav-toc-active-state branch from d1dac25 to 56c621c Compare August 2, 2023 14:27
@codecov
Copy link

codecov bot commented Aug 2, 2023

Codecov Report

Patch and project coverage have no change.

Comparison is base (cf2d134) 77.56% compared to head (548659c) 77.57%.
Report is 5 commits behind head on main.

❗ Current head 548659c differs from pull request most recent head 378967f. Consider uploading reports for the commit 378967f to get more accurate results

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #9038   +/-   ##
=======================================
  Coverage   77.56%   77.57%           
=======================================
  Files         591      591           
  Lines       24577    24577           
=======================================
+ Hits        19064    19065    +1     
+ Misses       5513     5512    -1     

see 2 files with indirect coverage changes

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@yufeih yufeih added the bug-fix Makes the pull request to appear in "Bug Fixes" section of the next release note label Aug 3, 2023
templates/modern/src/nav.ts Outdated Show resolved Hide resolved
templates/modern/src/toc.ts Outdated Show resolved Hide resolved
@Lulalaby
Copy link
Contributor Author

Lulalaby commented Aug 3, 2023

@yufeih i'm unsure about how to specially add a test for the "active" variable, but I can't spend more time to figure it out.
Gonna go in a few hours to my doc, kinda emergency surgical intervention.. so ig i'm out for a while.

I hope that pr is good to go, otherwise I'd be happy if someone could fix it.

@Lulalaby
Copy link
Contributor Author

Lulalaby commented Aug 3, 2023

image
I noticed that it's difficult to test in forks. Can we change that to take the repo / org from var?

@Lulalaby Lulalaby force-pushed the fix/nav-toc-active-state branch 4 times, most recently from 548659c to ab70080 Compare August 3, 2023 12:27
@Lulalaby
Copy link
Contributor Author

Lulalaby commented Aug 3, 2023

btw what's up with /home/runner/work/docfx/docfx/samples/seed/articles/images/seed.jpg: No template bundle found for Resource, model will be ignored.

I noticed it since upgrading docfx

Sorry for the ci spam also, I tried fixing the snapshot ci. Doesn't work tho due to limited workflow permissions.

@Lulalaby Lulalaby requested a review from yufeih August 3, 2023 12:29
.github/workflows/ci.yml Outdated Show resolved Hide resolved
@Lulalaby Lulalaby force-pushed the fix/nav-toc-active-state branch from ab70080 to 378967f Compare August 3, 2023 12:59
Copy link
Contributor

@yufeih yufeih left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you @Lulalaby !

@yufeih yufeih merged commit fc7deda into dotnet:main Aug 3, 2023
@Lulalaby Lulalaby deleted the fix/nav-toc-active-state branch August 3, 2023 13:14
p-kostov pushed a commit to ErpNetDocs/docfx that referenced this pull request Jun 28, 2024
dotnet#9038)

* fix: nav & toc active state breaks with external urls

* chore: move check to helper & add tests
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug-fix Makes the pull request to appear in "Bug Fixes" section of the next release note
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants