Skip to content
This repository was archived by the owner on Apr 12, 2024. It is now read-only.

Docs: Internal hash-links' hrefs on docs.angularjs.org all lead to the docs home page #16608

Closed
1 of 3 tasks
mgol opened this issue Jun 22, 2018 · 2 comments
Closed
1 of 3 tasks

Comments

@mgol
Copy link
Member

mgol commented Jun 22, 2018

I'm submitting a ...

  • bug report
  • feature request
  • other

Current behavior:

Internal hash-links on all doc pages (i.e. ones that are meant to just scroll the user to a section on the same page) are all broken, leading to the docs home page instead of the current one.

This seems to work - clicking on the links scroll to the correct place and the URL updates properly - but that's because Angular.js intercepts the native browser navigation.

This is caused by the <base> tag that points to the main page, causing seemingly harmless hash-links like #migrating-from-1-6-to-1-7 to resolve against the document.baseURI instead of the current URL path name.

Expected / new behavior:

All the links should work when opened in a new tab.

Minimal reproduction of the problem with instructions:

If you try to open one of the links on a new page, e.g. via Ctrl+click (Windows/Linux) or Cmd+click (macOS) you'll get to the incorrect:
https://docs.angularjs.org/api#migrating-from-1-6-to-1-7
instead of the expected:
https://docs.angularjs.org/guide/migration#migrating-from-1-6-to-1-7

See e.g. how at https://docs.angularjs.org/guide/migration the "Migrating from 1.6 to 1.7" link behaves.

AngularJS version: N/A

The docs for older AngularJS versions don't suffer this issue, compare a correct:
https://code.angularjs.org/1.6.6/docs/guide/migration
with a broken:
https://code.angularjs.org/1.6.7/docs/guide/migration

Browser: all

Anything else:

@petebacondarwin
Copy link
Contributor

The problem is with the generated Table of Contents rather than links in general. Previously the manual ToCs had full paths with their hashes.

The generated ToC has always failed in this way. Here is the line that is at fault

'<a ng-href="#{{item.fragment}}">{{item.title}}</a>' +

petebacondarwin added a commit to petebacondarwin/angular.js that referenced this issue Jun 22, 2018
Without the path the browser address changes so the hash
fragment is directly on the base url. Then on refresh the
browser navigates to an invalid page.

Closes angular#16608
petebacondarwin added a commit to petebacondarwin/angular.js that referenced this issue Jun 22, 2018
Without the path the link is always pointing to the
root page, rather than the current page, which means
that copying the link address or opening the page in
a new tab is broken.

Closes angular#16608
@petebacondarwin
Copy link
Contributor

I updated the commit message. Thanks @mgol

petebacondarwin added a commit that referenced this issue Jun 22, 2018
Without the path the link is always pointing to the
root page, rather than the current page, which means
that copying the link address or opening the page in
a new tab is broken.

Closes #16608
petebacondarwin added a commit that referenced this issue Jun 22, 2018
Without the path the link is always pointing to the
root page, rather than the current page, which means
that copying the link address or opening the page in
a new tab is broken.

Closes #16608
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants