From 8821ada1bba3d6b17336fc17da2a3b42dd240edc Mon Sep 17 00:00:00 2001 From: Renzo <170978465+RenzoMXD@users.noreply.github.com> Date: Wed, 29 Apr 2026 09:58:38 -0600 Subject: [PATCH] :bug: Suppress browser context menu on empty workspace sidebar space (#9196) Signed-off-by: RenzoMXD <170978465+RenzoMXD@users.noreply.github.com> Signed-off-by: Renzo <170978465+RenzoMXD@users.noreply.github.com> Co-authored-by: Andrey Antukh --- CHANGES.md | 1 + frontend/src/app/main/ui/workspace/sidebar.cljs | 3 +++ frontend/src/app/util/dom.cljs | 8 ++++++++ 3 files changed, 12 insertions(+) diff --git a/CHANGES.md b/CHANGES.md index 14f1699c0b..b9b42c551b 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -54,6 +54,7 @@ ### :bug: Bugs fixed +- Suppress the browser context menu when right-clicking empty space in the workspace sidebars while preserving it on text inputs so paste/select-all still work [Github #5127](https://github.com/penpot/penpot/issues/5127) - Fix release notes modal appearing behind the dashboard sidebar [Github #8296](https://github.com/penpot/penpot/issues/8296) - Fix plugin API `fileVersion.restore()` promise hanging indefinitely on restore failure [Github #9092](https://github.com/penpot/penpot/issues/9092) - Fix imported stroke-only SVG paths losing their rounded join when authoring tools (e.g. Figma → Heroicons) split a continuous polyline into adjacent `M…L M…L` subpaths sharing an endpoint; on import these are now folded back into one chain so `stroke-linejoin` renders the elbow correctly in both editor and exports [Github #5283](https://github.com/penpot/penpot/issues/5283) diff --git a/frontend/src/app/main/ui/workspace/sidebar.cljs b/frontend/src/app/main/ui/workspace/sidebar.cljs index ae43b60052..b1bfe74db9 100644 --- a/frontend/src/app/main/ui/workspace/sidebar.cljs +++ b/frontend/src/app/main/ui/workspace/sidebar.cljs @@ -42,6 +42,7 @@ [app.main.ui.workspace.sidebar.versions :refer [versions-toolbox*]] [app.main.ui.workspace.tokens.sidebar :refer [tokens-sidebar-tab*]] [app.util.debug :as dbg] + [app.util.dom :as dom] [app.util.i18n :refer [tr]] [potok.v2.core :as ptk] [rumext.v2 :as mf])) @@ -183,6 +184,7 @@ :data-testid "left-sidebar" :data-width (str width) :class aside-class + :on-context-menu dom/prevent-default-context-menu :style {:--left-sidebar-width (dm/str width "px")}} [:> left-header* {:file file @@ -329,6 +331,7 @@ :id "right-sidebar-aside" :data-testid "right-sidebar" :data-size (str width) + :on-context-menu dom/prevent-default-context-menu :style {:--right-sidebar-width (if can-be-expanded? (dm/str width "px") (dm/str right-sidebar-default-width "px"))}} diff --git a/frontend/src/app/util/dom.cljs b/frontend/src/app/util/dom.cljs index aa46be4497..2ce67382b1 100644 --- a/frontend/src/app/util/dom.cljs +++ b/frontend/src/app/util/dom.cljs @@ -122,6 +122,14 @@ (fn? (.-preventDefault event))) (.preventDefault event))) +(defn prevent-default-context-menu + [^js event] + (let [target (some-> event .-target) + tag (some-> target .-tagName .toLowerCase)] + (when-not (or (#{"input" "textarea"} tag) + (some-> target .-isContentEditable)) + (.preventDefault event)))) + (defn get-target "Extract the target from event instance." [^js event]