fix(web-components): prevent double tab open on Ctrl+click in BaseAnchor#35745
Merged
chrisdholt merged 7 commits intomicrosoft:masterfrom Feb 20, 2026
Merged
Conversation
📊 Bundle size report✅ No changes found |
|
Pull request demo site: URL |
Contributor
Author
|
Hi @chrisdholt @radium-v @marchbox @davatron5000 — could you please review this fix? It addresses a bug where Ctrl+click (or Cmd+click on Mac) on anchor-based components ( |
chrisdholt
reviewed
Feb 19, 2026
Member
chrisdholt
left a comment
There was a problem hiding this comment.
Thanks for this! Pulling it down to test/review locally
chrisdholt
approved these changes
Feb 20, 2026
davatron5000
approved these changes
Feb 20, 2026
eljefe223
approved these changes
Feb 20, 2026
marchbox
approved these changes
Feb 20, 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.
Bug
Ctrl+clicking (or Cmd+clicking on Mac) a component that extends
BaseAnchor— such as<fluent-link>or<fluent-anchor-button>— opens two tabs instead of one.Root Cause
BaseAnchor.clickHandlercallshandleNavigation(true)which invokeswindow.open(href, '_blank'), but does not calle.preventDefault(). The proxy<a>element (positioned withposition: absolute; inset: 0over the component) also receives the native Ctrl+click, causing the browser to open a second tab via its built-in modifier-click behavior.On Ctrl+click, two navigations fire:
<a href="...">clickHandler, which callswindow.openFix
Call
e.preventDefault()inclickHandlerwhen the modifier key is held (ctrlKeyon Windows/Linux,metaKeyon Mac), before callinghandleNavigation(). This lets the component handle new-tab navigation exclusively and prevents the native duplicate.Changed File
packages/web-components/src/anchor-button/anchor-button.base.ts— addede.preventDefault()guard inclickHandlerTesting
<fluent-link>now opens exactly one tabanchor-button.spec.tsCtrl+click Playwright test should continue to pass (it waits for one new page viacontext.waitForEvent('page'))