Fix Cmd/Ctrl-click on sub-page links not opening new tab - #5928
Merged
Conversation
The global click handler in sub_pages.js was intercepting all clicks on internal links, including modifier-key clicks (Cmd, Ctrl, Shift, Alt), preventing the browser from opening links in a new tab or window. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
evnchn
approved these changes
Apr 1, 2026
evnchn
left a comment
Collaborator
There was a problem hiding this comment.
Nice. I was wondering where's the coverage for the "Windows key" (Windows) and "Super key" (for Linux). Turns out both in metaKey, so yeah we got all keys.
Claude Code is saying that typically SPA do not exclude alt-click, but I think we should, since we have nothing to do with alt-click and we should not "occupy" it as such.
It'd be a different story if we want to add alt-click function, which I don't see in the long-term future.
8 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Motivation
When using
ui.linkinside aui.sub_pagescontext, Cmd-click (macOS) or Ctrl-click (Windows/Linux) does not open the link in a new browser tab. Instead, the click is intercepted by the sub-pages router and the navigation happens in the same tab. This breaks the standard browser behavior users expect from modifier-key clicks on links.Implementation
The global
clickevent listener insub_pages.jscallse.preventDefault()for all clicks on internal links (those starting with/) to handle client-side routing. However, it did not check for modifier keys before intercepting.The fix adds an early return when any modifier key (
metaKey,ctrlKey,shiftKey,altKey) is held during the click, allowing the browser to handle these events natively (e.g., open in new tab, open in new window, download).Progress