Skip to content

Conversation

@Rajdeepc
Copy link
Contributor

@Rajdeepc Rajdeepc commented Dec 15, 2025

Description

Fixes an issue where clicking sp-button or sp-action-button with href and target="_blank" attributes opened two browser tabs in Chrome instead of one.

Root cause

The ButtonBase component renders an anchor element with position: absolute; inset: 0 that overlays the entire button. When clicked:

  1. handleClickCapture catches the click and calls shouldProxyClick()anchorElement.click() → first navigation
  2. The original click event continues propagating and naturally reaches the anchor → second navigation

This only manifested in Chrome due to how it handles click event propagation on absolutely-positioned elements within shadow DOM.

Solution

Check if the anchor element is already in the click event's composedPath() before triggering a proxy click. If the anchor is in the path, the browser will handle navigation naturally and no proxy is needed.

const path = event?.composedPath() || [];
if (path.includes(this.anchorElement)) {
    return false;  // Skip proxy - browser handles it naturally
}

Motivation and context

Related issue(s)

  • fixes [SWC-921]

Screenshots (if appropriate)


Author's checklist

  • I have read the CONTRIBUTING and PULL_REQUESTS documents.
  • I have reviewed at the Accessibility Practices for this feature, see: Aria Practices
  • I have added automated tests to cover my changes.
  • I have included a well-written changeset if my change needs to be published.
  • I have included updated documentation if my change required it.

Reviewer's checklist

  • Includes a Github Issue with appropriate flag or Jira ticket number without a link
  • Includes thoughtfully written changeset if changes suggested include patch, minor, or major features
  • Automated tests cover all use cases and follow best practices for writing
  • Validated on all supported browsers
  • All VRTs are approved before the author can update Golden Hash

Manual review test cases

  • Modifier Clicks

    1. Go here
    2. Cmd+Click, Ctrl+Click
    3. Expect it to open a single new tab and not double
  • VO testing

    1. Go here
    2. CMD + F5 to enable, VO + Space to activate
    3. Expect it calls out as "link"
  • Keyboard Testing

    1. Go here
    2. Tab to focus, Enter/Space to activate
    3. Expect it calls out as "link"

Device review

  • Did it pass in Desktop?
  • Did it pass in (emulated) Mobile?
  • Did it pass in (emulated) iPad?

@changeset-bot
Copy link

changeset-bot bot commented Dec 15, 2025

⚠️ No Changeset found

Latest commit: d98a19c

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@github-actions
Copy link
Contributor

📚 Branch Preview Links

🔍 First Generation Visual Regression Test Results

When a visual regression test fails (or has previously failed while working on this branch), its results can be found in the following URLs:

Deployed to Azure Blob Storage: pr-5937

If the changes are expected, update the current_golden_images_cache hash in the circleci config to accept the new images. Instructions are included in that file.
If the changes are unexpected, you can investigate the cause of the differences and update the code accordingly.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants