Skip to content

fix(ui): open folder items in new tab on CMD/Shift+double-click#16001

Open
amateurbeekeeper wants to merge 1 commit intopayloadcms:mainfrom
amateurbeekeeper:fix/cmd-shift-double-click-new-tab
Open

fix(ui): open folder items in new tab on CMD/Shift+double-click#16001
amateurbeekeeper wants to merge 1 commit intopayloadcms:mainfrom
amateurbeekeeper:fix/cmd-shift-double-click-new-tab

Conversation

@amateurbeekeeper
Copy link

What I did

Fixes #15837

When navigating the folder view, holding CMD or Shift while double-clicking a file card or table row now opens the item in a new browser tab.

Root cause

Two things were broken:

1. No new-tab support in navigateAfterSelection — navigation always went through router.push(), which navigates in-place. Folder cards and draggable table rows are div/tr elements with pointer event handlers, not <a> tags, so the browser's native new-tab behaviour never fired.

2. Modifier-key double-click was undetectable — the double-click check only ran in the else branch (normal click), after the isCtrlPressed/isShiftPressed checks. So CMD/Shift+double-click was intercepted for multi-selection before double-click detection ever ran. Also, the previous detection used dragOverlayItem as a proxy for "last clicked item", but dragOverlayItem isn't reliably set during modifier-key clicks.

Fix

providers/Folders/index.tsx

  1. Add a lastClickItemKey ref to reliably track the last-clicked item, independent of dragOverlayItem.
  2. Move double-click detection to before the modifier-key branches, so CMD/Shift+double-click is caught first.
  3. Add newTab?: boolean to navigateAfterSelection — when true, calls window.open(url, '_blank') instead of router.push().

Behaviour

Action Before After
Single click select item select item (unchanged)
Double click navigate in same tab navigate in same tab (unchanged)
CMD/Shift + single click multi-select multi-select (unchanged)
CMD/Shift + double click multi-select (broken) open in new tab ✓

🤖 Generated with Claude Code

When navigating the folder view, holding CMD or Shift while double-clicking
a file card or table row now opens the target URL in a new browser tab
instead of navigating in the current tab.

Previously, all navigation went through router.push() which always
navigates in-place. The browser's native new-tab behaviour (triggered by
modifier keys on <a> elements) never fired because folder cards and
draggable table rows are div/tr elements with pointer event handlers.

Additionally, CMD/Shift single-click was intercepted for multi-selection
before the double-click detection ran, so modifier-key double-clicks were
impossible to detect. Fix by:

  1. Moving double-click detection before the modifier-key branches and
     tracking last-clicked item in a dedicated ref (lastClickItemKey)
     rather than reusing dragOverlayItem, so modifier-key single-clicks
     still count toward the next double-click.

  2. Adding a newTab option to navigateAfterSelection that calls
     window.open(url, '_blank') instead of router.push().

CMD/Shift single-click still performs multi-select as before.

Fixes payloadcms#15837

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

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

1 participant