mirror of
https://github.com/penpot/penpot.git
synced 2026-10-29 05:50:35 +00:00
✨ Open files and projects in a new tab with Ctrl/Cmd+click (#12230)
Ctrl+click (Cmd+click on macOS) on a dashboard file card, a project title, the "Show all files" button, or a project or Drafts item in the sidebar now opens it in a new browser tab. It reuses the same `::rt/new-window` navigation as the "Open in new tab" file menu option. On file cards the modifier click does not change the selection, and a modifier double click does not navigate the current tab. Files in the trash are not opened. Closes #12228 AI-assisted-by: claude-opus-5-5
This commit is contained in:
parent
6f34794f54
commit
89c6bad8cd
@ -23,6 +23,7 @@
|
||||
[app.main.refs :as refs]
|
||||
[app.main.render :as render]
|
||||
[app.main.repo :as rp]
|
||||
[app.main.router :as rt]
|
||||
[app.main.store :as st]
|
||||
[app.main.ui.components.color-bullet :as bc]
|
||||
[app.main.ui.dashboard.file-menu :refer [file-menu* file-menu-items*]]
|
||||
@ -293,22 +294,35 @@
|
||||
|
||||
library-view? (= origin :libraries)
|
||||
|
||||
on-open-new-tab
|
||||
(mf/use-fn
|
||||
(mf/deps file-id can-restore)
|
||||
(fn []
|
||||
(when-not can-restore
|
||||
(st/emit! (dcm/go-to-workspace :file-id file-id ::rt/new-window true)))))
|
||||
|
||||
on-select
|
||||
(mf/use-fn
|
||||
(mf/deps selected? selected-num)
|
||||
(mf/deps selected? selected-num on-open-new-tab)
|
||||
(fn [event]
|
||||
(when (or (not selected?) (> selected-num 1))
|
||||
(dom/stop-propagation event)
|
||||
(let [shift? (kbd/shift? event)]
|
||||
(when-not shift?
|
||||
(st/emit! (dd/clear-selected-files)))
|
||||
(st/emit! (dd/toggle-file-select file))))))
|
||||
(if (kbd/mod? event)
|
||||
(do
|
||||
(dom/stop-propagation event)
|
||||
(on-open-new-tab))
|
||||
(when (or (not selected?) (> selected-num 1))
|
||||
(dom/stop-propagation event)
|
||||
(let [shift? (kbd/shift? event)]
|
||||
(when-not shift?
|
||||
(st/emit! (dd/clear-selected-files)))
|
||||
(st/emit! (dd/toggle-file-select file)))))))
|
||||
|
||||
on-navigate
|
||||
(mf/use-fn
|
||||
(mf/deps file-id can-restore)
|
||||
(fn [event]
|
||||
(when-not can-restore
|
||||
;; A Ctrl/Cmd double click has already opened the file in new
|
||||
;; tabs through on-select; the current tab stays where it is.
|
||||
(when-not (or can-restore (kbd/mod? event))
|
||||
(let [menu-icon (mf/ref-val menu-ref)
|
||||
target (dom/get-target event)]
|
||||
(when-not (dom/child? target menu-icon)
|
||||
|
||||
@ -16,6 +16,7 @@
|
||||
[app.main.data.project :as dpj]
|
||||
[app.main.data.team :as dtm]
|
||||
[app.main.refs :as refs]
|
||||
[app.main.router :as rt]
|
||||
[app.main.store :as st]
|
||||
[app.main.ui.components.mcp-menu :refer [dashboard-mcp-menu*]]
|
||||
[app.main.ui.dashboard.deleted :as deleted]
|
||||
@ -127,8 +128,9 @@
|
||||
on-nav
|
||||
(mf/use-fn
|
||||
(mf/deps project-id)
|
||||
(fn []
|
||||
(st/emit! (dcm/go-to-dashboard-files :project-id project-id))))
|
||||
(fn [event]
|
||||
(st/emit! (dcm/go-to-dashboard-files :project-id project-id
|
||||
::rt/new-window (kbd/mod? event)))))
|
||||
|
||||
toggle-pin
|
||||
(mf/use-fn
|
||||
@ -286,7 +288,7 @@
|
||||
:tab-index "0"
|
||||
:on-key-down (fn [event]
|
||||
(when (kbd/enter? event)
|
||||
(on-nav)))}
|
||||
(on-nav event)))}
|
||||
(tr "dashboard.show-all-files")
|
||||
[:> icon* {:icon-id i/arrow-right}]])]]
|
||||
|
||||
|
||||
@ -89,8 +89,9 @@
|
||||
on-click
|
||||
(mf/use-fn
|
||||
(mf/deps project-id)
|
||||
(fn []
|
||||
(st/emit! (dcm/go-to-dashboard-files :project-id project-id))))
|
||||
(fn [event]
|
||||
(st/emit! (dcm/go-to-dashboard-files :project-id project-id
|
||||
::rt/new-window (kbd/mod? event)))))
|
||||
|
||||
on-key-down
|
||||
(mf/use-fn
|
||||
@ -297,8 +298,10 @@
|
||||
go-drafts
|
||||
(mf/use-fn
|
||||
(mf/deps team-id default-project-id)
|
||||
(fn []
|
||||
(st/emit! (dcm/go-to-dashboard-files :team-id team-id :project-id default-project-id))))
|
||||
(fn [event]
|
||||
(st/emit! (dcm/go-to-dashboard-files :team-id team-id
|
||||
:project-id default-project-id
|
||||
::rt/new-window (kbd/mod? event)))))
|
||||
|
||||
go-drafts-with-key
|
||||
(mf/use-fn
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user