dotnet / dotnet/docfx

[Bug] Item it toc.yml without topicUid links the parent page causing side-effects because of multiple links pointing to the same page

Open
#8,891 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
C#
Stars
4.4k
Forks
890
Avg merge
2h 11m
Merged PRs (30d)
10

Description

**Describe the bug**

In previous versions of docfx (ca. 2.59.x), this kind of toc would work as expected:

```yaml
- name: How To...
items:
- name: Migrate to RazorComponent
topicUid: NetCode.Razor.MigrateToV10
```

The item `How To...` didn't have an own link, which was fine.

Now using 2.67.2 the `How To...` has a link, specifically pointing to the parent page.
This sounds harmless, but it breaks the behavior of clicking on a parent page.
So if I go to http://docs2sxc.dnndev.me/net-code/index.html and click on this link:

![image](https://github.com/dotnet/docfx/assets/5321186/145b55be-3285-4072-9ef6-bd31ffe6f11a)

It _should_ look like this:
![image](https://github.com/dotnet/docfx/assets/5321186/b410737f-caca-4193-98ba-0969731671cc)

BUT it immediately scrolls down to:

![image](https://github.com/dotnet/docfx/assets/5321186/ab339771-05db-4586-b5ee-9297f8baa00b)

Because `How to...` has the same link, and the "scroll to selected " will scroll to the last selected link with that target.

**To Reproduce**

1. Create some tocs - make sure that you have many, so that toc-scrolling is necessary
2. Further down create some `item` without a `href` or `topicUid` etc.
3. Observe that the generated HTML does actually have a link on it (bug)
4. click on another link that should go to the same url - and it will scroll to the title which _shouldn't_ have a link

**Context (please complete the following information):**
- OS: Windows
- Docfx version: 2.67.2 but probably many before (we skipped many version

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.