Skip to content

fix-ui-modifier-key-new-tab#15920

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

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
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

Copilot AI review requested due to automatic review settings March 12, 2026 01:23
@github-actions
Copy link
Contributor

github-actions bot commented Mar 12, 2026

Pull Request titles must follow the Conventional Commits specification and have valid scopes.

No release type found in pull request title "fix-ui-modifier-key-new-tab". Add a prefix to indicate what kind of release this pull request corresponds to. For reference, see https://www.conventionalcommits.org/

Available types:

  • build
  • chore
  • ci
  • docs
  • examples
  • feat
  • fix
  • perf
  • refactor
  • revert
  • style
  • templates
  • test
feat(ui): add Button component
^    ^    ^
|    |    |__ Subject
|    |_______ Scope
|____________ Type

Copy link
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.

@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
Contributor

jhb-dev commented Mar 12, 2026

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

@ossaidqadri
Copy link
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.

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

3 participants