Repository navigation
Don't open two browser tabs when clicking the pull request number - #8962
Merged
Alex Ross (alexr00) merged 5 commits intoOct 8, 2026
Merged
Conversation
02ac4de gave the pull request number links in the overview header and the sticky header an onClick that calls preventDefault and opens the item on GitHub, so that the link also works in the Agents window. The webview host opens any anchor with an href as well, and its click handler does not check defaultPrevented, so in a regular window the click is handled twice and the browser gets two tabs for the same URL. Stop the click from reaching the host, the way the code reference link handler in webviews/editorWebview/app.tsx already does. Fixes microsoft#8955
…ens-two-tabs main moved the title's PR number link into TitleText (microsoft#9009), so the stopPropagation this branch adds to that link moves with it. The test file keeps both sides' new tests.
Alex Ross (alexr00)
approved these changes
Oct 8, 2026
Alex Ross (alexr00)
left a comment
Member
There was a problem hiding this comment.
Thank you for the PR (and for your patience)!
Alex Ross (alexr00)
previously approved these changes
Oct 8, 2026
Alex Ross (alexr00)
left a comment
Member
There was a problem hiding this comment.
Thank you for the PR (and for your patience)!
Alex Ross (alexr00)
enabled auto-merge (squash)
October 8, 2026 12:59
Alex Ross (alexr00)
approved these changes
Oct 8, 2026
Contributor
There was a problem hiding this comment.
🟢 Approval recommended
All reviewed changes are covered by regression tests with no unresolved issues.
0 open findings
1 resolved since last review
🧠 Review effort: Lite
Give feedback about Copilot approvals in this survey to enter a drawing for a $150 gift card.
Member
|
/AzurePipelines run |
|
Azure Pipelines: 2 pipeline(s) were filtered out due to trigger conditions. |
Ulugbek Abdullaev (ulugbekna)
approved these changes
Oct 8, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Fixes #8955
Cause
Not #8919, which the issue guesses at — that PR does not touch link handling. The
regression is 02ac4de ("Fix various things in the webview that don't work correctly in
Agents window", #8935), which fixed #8934 by giving the
#<number>links inwebviews/components/header.tsxandwebviews/components/stickyHeader.tsxanonClick:Both anchors keep their
href, and the webview host opens any anchor with anhrefon itsown.
handleInnerClickinsrc/vs/workbench/contrib/webview/browser/pre/index.html(microsoft/vscode) is registeredwith
contentWindow.addEventListener('click', handleInnerClick)and postsdid-click-linkfor the first anchor in the click's composed path. It does not check
event.defaultPrevented— thecontextmenuhandler registered a few lines below it does.React 16 delegates
onClickatdocument, sopreventDefault()runs and the event thencarries on bubbling to the content
window, where the host handler runs regardless.One click therefore produces two opens:
did-click-link→IOpenerService.openpr.openOnGitHub→openItemOnGitHub(src/commands.ts) →openWithDefaultExternalOpenerWith
githubPullRequests.openPullLinksoff — its default since #8942 — nothing claims thefirst one, so both reach the browser: the two tabs in the report. With the setting on, the
extension's own external URI opener claims the
did-click-linkand re-reveals the overviewinstead, so the duplicate is less visible but still there.
These two anchors are the only ones under
webviews/that carry both anhrefand anonClick; every other<a onClick>in the tree has nohref, which is why they were neveraffected.
Fix
Stop the click from reaching the host, so exactly one code path opens the URL.
webviews/editorWebview/app.tsxalready does this for code reference links, with acapture-phase listener that calls
preventDefault()andstopPropagation().Keeping the
hrefpreserves the hover target, keyboard activation and the copy-link contextmenu; dropping the
onClickinstead would bring #8934 back, so the Agents-window path staysexactly as #8935 left it.
Arguably the deeper defect is that
handleInnerClickshould honourdefaultPreventedtheway the neighbouring
contextmenuhandler does. That lives in microsoft/vscode, so thischange does not wait on it.
Test
webviews/editorWebview/test/overview.test.tsxgainsopens a PR number link exactly once.It registers the host's behaviour on
window: it opens any anchor with anhrefthat the click reaches, without checkingdefaultPrevented. The test then clicks each number link and asserts oneopenOnGitHubcall and no host open, so exactly one external open per click.Update after merging
main(35ab0ca):mainnow runs the webview tests innpm testthroughtest:webviews(scripts/test-webviews.js), so the section that used to be here, saying these tests ran nowhere, no longer applies.mainalso moved the title's number link intoTitleText(#9009), and the fix moved with it. On this branch,node scripts/test-webviews.jsgives 39 passing, 0 failing, including the new test andapplies deferred pull request updates, which used to fail on its own. With thestopPropagation()inTitleTextremoved, the new test fails (38 passing, 1 failing).Validation
npm run compile— success (extension:node,extension:webworker,webviews)npm run lint— exit 0, no files changednpm run hygiene— exit 0npm run check:commands— all declared commands are registerednpm test— 559 passing, 0 failing (test:scripts75 passing, extension host suite exit 0)npx tsc --noEmitfortsconfig.json,tsconfig.webviews.jsonandtsconfig.test.json— all cleanFile and line references are against
main@2f06150a, and microsoft/vscodemain@f80869ac.