fix(button): double tab navigation when clicking button/action-button with href and target="_blank" #5937
+7
−0
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.
Description
Fixes an issue where clicking
sp-buttonorsp-action-buttonwithhrefandtarget="_blank"attributes opened two browser tabs in Chrome instead of one.Root cause
The
ButtonBasecomponent renders an anchor element withposition: absolute; inset: 0that overlays the entire button. When clicked:handleClickCapturecatches the click and callsshouldProxyClick()→anchorElement.click()→ first navigationThis 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.Motivation and context
Related issue(s)
Screenshots (if appropriate)
Author's checklist
Reviewer's checklist
patch,minor, ormajorfeaturesManual review test cases
Modifier Clicks
VO testing
Keyboard Testing
Device review