From e713c307856f2d87c53ab6834015dbcb06e74c64 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9s=20Moya?= Date: Tue, 2 Feb 2021 14:44:14 +0100 Subject: [PATCH] :bug: Prevent browser dragging of images in some cases --- frontend/src/app/main/ui/shapes/image.cljs | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/frontend/src/app/main/ui/shapes/image.cljs b/frontend/src/app/main/ui/shapes/image.cljs index e399d437bf..954b73efb5 100644 --- a/frontend/src/app/main/ui/shapes/image.cljs +++ b/frontend/src/app/main/ui/shapes/image.cljs @@ -13,6 +13,7 @@ [app.config :as cfg] [app.common.geom.shapes :as geom] [app.main.ui.shapes.attrs :as attrs] + [app.util.dom :as dom] [app.util.object :as obj] [app.main.ui.context :as muc] [app.main.data.fetch :as df] @@ -43,7 +44,11 @@ :transform transform :width width :height height - :preserveAspectRatio "none"}))] + :preserveAspectRatio "none"})) + on-drag-start (fn [event] + ;; Prevent browser dragging of the image + (dom/prevent-default event))] + (if (nil? @data-uri) [:> "rect" (obj/merge! props @@ -51,4 +56,5 @@ :stroke "#000000"})] [:> "image" (obj/merge! props - #js {:xlinkHref @data-uri})])))) + #js {:xlinkHref @data-uri + :onDragStart on-drag-start})]))))