Skip to content

fix(ui): modifier-key-new-tab#15920

Closed
ossaidqadri wants to merge 2 commits intopayloadcms:mainfrom
ossaidqadri:fix/15837-cmd-shift-click-new-tab
Closed

fix(ui): modifier-key-new-tab#15920
ossaidqadri wants to merge 2 commits intopayloadcms:mainfrom
ossaidqadri:fix/15837-cmd-shift-click-new-tab

Conversation

@ossaidqadri
Copy link
Copy Markdown
Contributor

Fixes #15837

Description

This PR adds support for opening list entries and folder cards in new tabs when using modifier keys (Cmd/Ctrl+Click or Shift+Click), matching standard web browser behavior.

Changes

  • packages/ui/src/elements/Table/DefaultCell/index.tsx: Added modifier key handling for table cell clicks
  • packages/ui/src/providers/Folders/index.tsx: Added modifier key handling for folder card clicks

Security

  • URLs are validated before opening (same-origin + http/https protocol check)
  • window.open() uses 'noopener,noreferrer' to prevent reverse tabnabbing
  • Extracted duplicated URL construction logic to helper function

Testing

  • TypeScript compilation passes
  • Cmd/Ctrl+Click opens items in new tab
  • Shift+Click opens items in new tab
  • Regular click behavior unchanged

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR attempts to add “open in new tab/window” behavior (Cmd/Ctrl/Shift+click) for items in the folder browser and for clickable table cells in the admin UI, aiming to align modifier-click behavior with standard web link interactions.

Changes:

  • Add modifier-click handling in the folder item click handler to open the clicked document in a new tab/window.
  • Add modifier-click handling for DefaultCell when it renders as a button to open the corresponding document URL in a new tab/window.
  • Refactor default collection item URL generation in DefaultCell into a small helper (getItemUrl).

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.

File Description
packages/ui/src/providers/Folders/index.tsx Adds modifier-click logic to open documents in a new tab/window from the folder view, altering existing selection behavior.
packages/ui/src/elements/Table/DefaultCell/index.tsx Adds modifier-click logic for button-rendered cells and deduplicates URL construction via getItemUrl.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread packages/ui/src/providers/Folders/index.tsx
Comment thread packages/ui/src/providers/Folders/index.tsx Outdated
Comment thread packages/ui/src/elements/Table/DefaultCell/index.tsx
@ossaidqadri ossaidqadri changed the title fix/15837 cmd shift click new tab fix-ui-modifier-key-new-tab Mar 12, 2026
@jhb-dev
Copy link
Copy Markdown
Contributor

jhb-dev commented Mar 12, 2026

Hi @ossaidqadri, fyi, this looks like a duplicate of #15873

@ossaidqadri
Copy link
Copy Markdown
Contributor Author

Thanks @jhb-dev for pointing this out!

I just reviewed #15873 and noticed it has the same bugs that the reviewer comments identified in my PR:

Issues in #15873:

  1. Protocol regex is /^https?$/ (missing colon) - will never match because URL.protocol returns https: with trailing colon
  2. Removes multi-selection behavior - Ctrl/Cmd+Click and Shift+Click for range selection are completely removed

My PR #15920 fixes both:

  1. Protocol regex: /^https?:$/ (with colon) - actually works
  2. Preserves multi-selection: Ctrl/Cmd toggles, Shift selects range, Alt opens new tab
  3. Also fixes the same bug in DefaultCell/index.tsx (table cells)
  4. 28 comprehensive tests covering all modifier key behaviors

Both PRs solve the same user need, but mine addresses the code review feedback and is more complete. Happy to coordinate with @mibragimov on the best path forward - whether that's closing this in favor of theirs (with the bugs fixed) or vice versa.

@denolfe denolfe changed the title fix-ui-modifier-key-new-tab fix(ui): modifier-key-new-tab Mar 17, 2026
@paulpopus
Copy link
Copy Markdown
Contributor

This PR needs e2e tests that verifies the functionality in multiple places to avoid regressions. Use the playwright utils to simulate the keybinds, there must be a way to simulate them for both windows and macos

@paulpopus
Copy link
Copy Markdown
Contributor

On a deeper review I'm closing this PR and it's something we should address and fix in v4 due to the new UI/UX considerations.

@paulpopus paulpopus closed this Apr 10, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

CMD/Shift + Click does not open list/folder links in new tab

5 participants