Skip to content

Commit

Permalink
Only try to scroll to element when the target path exactly matches th…
Browse files Browse the repository at this point in the history
…e base path of the current page

Fixes #121045

For pages that set `<base>`, if the target of link click goes to different path than the current page (taken from `base`), treat it as a normal link open instead
  • Loading branch information
mjbvz committed Apr 15, 2021
1 parent 0a6309b commit be2026c
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/vs/workbench/contrib/webview/browser/pre/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -324,8 +324,8 @@ export async function createWebviewManager(host) {
if (node.tagName && node.tagName.toLowerCase() === 'a' && node.href) {
if (node.getAttribute('href') === '#') {
event.view.scrollTo(0, 0);
} else if (node.hash && (node.getAttribute('href') === node.hash || (baseElement && node.href.indexOf(baseElement.href) >= 0))) {
let scrollTarget = event.view.document.getElementById(node.hash.substr(1, node.hash.length - 1));
} else if (node.hash && (node.getAttribute('href') === node.hash || (baseElement && node.href === baseElement.href + node.hash))) {
const scrollTarget = event.view.document.getElementById(node.hash.substr(1, node.hash.length - 1));
if (scrollTarget) {
scrollTarget.scrollIntoView();
}
Expand Down

0 comments on commit be2026c

Please sign in to comment.