Skip to content

A target="_blank" link in a preview tab replaces the page instead of opening a new tab #13953

Description

@jamesvillarrubia

Title: A target="_blank" link in a preview tab replaces the page instead of opening a new tab

Reproduction

  1. Serve any page with <a href="https://github.com/" target="_blank">x</a>.
  2. Open it in a T3 Code preview tab (observed on T3Code(Nightly)/0.0.43-nightly.20260925.2251, Electron, Chrome 152).
  3. Click the link.

Observed: the preview tab's URL becomes https://github.com/...; the original page is gone.
Also observed: window.open(url, '_blank', 'noopener') from the page returns null and does the same thing.
Expected: the page stays, and the link opens in a new preview tab.

Cause

apps/desktop/src/preview/Manager.ts:559 (same on main at 4293433ecc):

export const previewWindowOpenAction = (details: {
  readonly url: string;
  readonly disposition: Electron.HandlerDetails["disposition"];
}): "popup" | "navigate" =>
  details.disposition === "new-window" && isPopupUrl(details.url) ? "popup" : "navigate";

Manager.ts:2053 acts on "navigate" by calling wc.loadURL(details.url) on the same preview webContents and returning { action: "deny" }.

This path predates #8435, which added the OAuth popup case for new-window and left the load-in-place behavior for everything else, including an explicit target="_blank" request.

Fix

PR incoming: previewWindowOpenAction returns a third "new-tab" result for a foreground-tab/background-tab disposition with an http(s) URL, and the link opens as a new preview tab instead of navigating the original.

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions