Skip to content

RouterLink should support _blank, _self, _top targets #5791

Closed

Description

@khauser

Is this possible? (like already for Anchor)

Activity

  1. khauser commented on Jun 24, 2019

    @khauser
    Author

    ah, it's a PWA

  2. pleku commented on Oct 9, 2019

    @pleku

    Hi @khauser , care to elaborate what type of UX you're after? Is it e.g. to be able to get the user to open a navigation target (@Route) in a new window, like using _blank ?

    For that case actually the Achor component should be used instead of RouterLink and the browser will handle everything for you. But it does lack the similar API as RouterLink to create the link easily based on a registered route in the application.

  3. mvysny commented on Sep 30, 2026

    @mvysny
    Member

    The use case: open a route in a new tab while keeping RouterLink's typed route API. That means the route class + parameters, setQueryParameters() and HighlightCondition. With Anchor I have to build the URL by hand through RouteConfiguration.getUrl(), and the highlighting is gone. Ctrl/middle-click already opens a RouterLink in a new tab, but users don't know it, and the app can't ask for it.

    Proposal, the same shape SideNavItem already has:

    public void setTarget(String target)   // null or "" removes the attribute
    public String getTarget()              // null when unset
    public void setOpenInNewBrowserTab(boolean openInNewBrowserTab)  // sets or removes "_blank"
    public boolean isOpenInNewBrowserTab()

    AnchorTargetValue can't appear in the signature. It lives in flow-html-components, which depends on flow-server, where RouterLink lives.

    Verified on Vaadin 25.2.9 with the React router: with target="_blank" set on the element, the client router leaves the click alone (Flow.tsx extractURL() skips any target other than _self), no RPC reaches the server, and the route opens in a new tab with a fresh UI. _self is still routed in place. So this needs server API only, no client change. Workaround until then: routerLink.getElement().setAttribute("target", "_blank").

    If this shape is OK, I'll send a PR against 25.

  4. added a commit that references this issue on Oct 20, 2026
    3f5b0b9
  5. vaadin-bot commented on Oct 22, 2026

    @vaadin-bot
    Collaborator

    This ticket/PR has been released with Vaadin 25.4.0-alpha4.

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions