chore: support cmd click on all clickable items#10350
Merged
Conversation
54f0720 to
330e2d2
Compare
330e2d2 to
ec5b542
Compare
5 tasks
H4ad
reviewed
Feb 25, 2026
ec5b542 to
32d7216
Compare
H4ad
reviewed
Mar 9, 2026
frontend/src/container/InfraMonitoringK8s/Clusters/K8sClustersList.tsx
Outdated
Show resolved
Hide resolved
H4ad
previously approved these changes
Mar 9, 2026
…e unused test file
H4ad
previously approved these changes
Mar 18, 2026
frontend/src/container/InfraMonitoringK8s/Nodes/K8sNodesList.tsx
Outdated
Show resolved
Hide resolved
makeavish
approved these changes
Mar 30, 2026
AshwinBhatkal
approved these changes
Mar 30, 2026
tushar-signoz
pushed a commit
that referenced
this pull request
Mar 30, 2026
* chore: support cmd click on all clickable items * chore: update test cases * feat: address review comments * feat: enhance navigation tests for middle mouse button interactions * refactor: update navigation handling to use safeNavigate with newTab option * feat: support opening links in new tab with modifier key in K8sPodsList and SideNav * chore: clean up environment variable usage in login utility and remove unused test file * refactor: update import order and adjust navigation call in AlertNotFound tests * chore: remove eslint disable * chore: move isModiferKey to app util file * feat: update buildAbsolutePath to handle empty relative path * chore: fix import error
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.
Pull Request
Summary
Users expect Cmd+Click (Mac) / Ctrl+Click (Windows/Linux) on clickable items to open the target in a new browser tab - a universal web convention. Currently, SPA navigation via
safeNavigatealways replaces the current page, ignoring modifier keys. Several components (e.g.DashboardsList,ListAlert) had ad-hocevent.metaKey || event.ctrlKeychecks withwindow.open, leading to duplicated logic and inconsistent coverage.This PR centralizes modifier-key detection in
useSafeNavigateby accepting an optionaleventparameter. When a click event is provided and Cmd/Ctrl is held, the hook automatically opens the target in a new tab instead of performing SPA navigation. A sharedutils/navigation.tsmodule provides the low-level helpers (isModifierKeyPressed,openInNewTab,navigateToPage) for cases outside the hook.50 files are updated to thread the mouse event from click handlers into
safeNavigate, covering: homepage service tables, infra monitoring K8s lists (Pods, Nodes, Clusters, Deployments, etc.), hosts list, alert rules, dashboards list, metrics explorer, side nav, onboarding flows, messaging queues, breadcrumbs, and more. Two files (DashboardsList,ListAlert) that had duplicated manual Cmd/Ctrl detection were refactored to use the centralized approach.Screenshots / Screen Recordings (if applicable)
N/A - behavioral change: hold Cmd/Ctrl while clicking any navigable row, link, or button to open in a new tab.
Issues closed by this PR
Change Type
Select all that apply
Bug Context
N/A - this is a new feature / UX enhancement, not a bug fix.
Testing Strategy
src/utils/__tests__/navigation.test.ts- 15 tests coveringisModifierKeyPressed,openInNewTab, andnavigateToPagewith various modifier key combinations, edge cases (both metaKey and ctrlKey), and fallback to SPA navigation.src/hooks/__tests__/useSafeNavigate.test.ts- 9 tests verifying the mock contract acceptseventandnewTaboptions, and that theshouldOpenNewTabdecision logic correctly combines explicitnewTabwith modifier-key detection.metaKey(Mac) andctrlKey(Windows/Linux),newTab: truewithout event, event without modifier keys, bothnewTaband modifier keys simultaneously.Risk & Impact Assessment
onClickthat provides a non-standard event shape,isModifierKeyPressedwill safely returnfalse(checkingmetaKey/ctrlKeyon undefined returns falsy).MetricsApplication/Tabs/util.tschanged return type fromVoidFunctionto(e?: React.MouseEvent) => void- callers passing these asonClickhandlers are compatible since React'sonClickprovides the event as the first argument.Changelog
Checklist
Notes for Reviewers
Core changes (read first):
src/utils/navigation.ts- new shared helpers for modifier-key detectionsrc/hooks/useSafeNavigate.ts- acceptseventoption, auto-detects Cmd/Ctrl__mocks__/useSafeNavigate.ts- mock updated to match new interfacePattern across all 50 files:
Reactimport (forReact.MouseEventtype)onClickhandler intosafeNavigate(..., { event })onRowhandlers: change callback signature to accept(record, event)and passeventthroughRefactored duplicated logic:
DashboardsList.tsx- removed manualevent.metaKey || event.ctrlKey+window.open(6 lines to 1 line)ListAlert.tsx- replacedopenInNewTab: booleanparameter with{ event?, newTab? }options object, removed manualwindow.openbranchIntentionally not changed -
safeNavigatecalls insideuseEffect,onSuccessmutation callbacks,setTimeout, drag handlers, and paginationonChangehandlers where noMouseEventis available. These are programmatic navigations where Cmd+Click does not apply.