@@ -126,10 +126,12 @@ export function findProjectOnChangeRequestHost(
126126 *
127127 * With "Open pull requests in T3 Code" turned off, every link is left alone.
128128 */
129+ /** Cmd/Ctrl-click and middle-click send a pull request to the browser instead of the panel. */
129130export function shouldOpenPullRequestExternally (
130- event : Pick < MouseEvent < HTMLElement > , "metaKey" | "ctrlKey" > ,
131+ event : Pick < MouseEvent < HTMLElement > , "metaKey" | "ctrlKey" > &
132+ Partial < Pick < MouseEvent < HTMLElement > , "button" > > ,
131133) : boolean {
132- return event . metaKey || event . ctrlKey ;
134+ return event . metaKey || event . ctrlKey || event . button === 1 ;
133135}
134136
135137export function useOpenChangeRequestLink (
@@ -256,11 +258,13 @@ export function useOpenPrLink(threadRef?: ScopedThreadRef) {
256258 const openLink = useOpenLink ( threadRef ) ;
257259 return useCallback (
258260 ( event : MouseEvent < HTMLElement > , prUrl : string , targetThreadRef ?: ScopedThreadRef ) => {
261+ // Buttons also pass this to onAuxClick for middle-click; a right-click is not an open.
262+ if ( event . button > 1 ) return false ;
259263 event . stopPropagation ( ) ;
260264 const openInBrowser = shouldOpenPullRequestExternally ( event ) ;
261265 const isAnchor =
262266 event . currentTarget instanceof HTMLAnchorElement && event . currentTarget . href . length > 0 ;
263- // A real link already knows how to cmd/ctrl+ click. Leave its default
267+ // A real link already knows how to cmd/ctrl/middle- click. Leave its default
264268 // action alone so the browser (or Electron's window-open handler) opens
265269 // the host. Buttons have no href, so they still go through openExternal.
266270 if ( openInBrowser && isAnchor ) return false ;
0 commit comments