0
Fork 0
mirror of https://github.com/penpot/penpot.git synced 2025-01-10 00:40:30 -05:00

🐛 Fix drag and drop in the dashboard generates import file error message

This commit is contained in:
Alejandro Alonso 2023-07-04 07:17:13 +02:00 committed by Alonso Torres
parent 8b0339bbab
commit 0d87dc5680

View file

@ -495,17 +495,20 @@
(mf/use-fn (mf/use-fn
(mf/deps selected-project) (mf/deps selected-project)
(fn [e] (fn [e]
(when (dnd/has-type? e "penpot/files") (cond
(dom/prevent-default e) (dnd/has-type? e "penpot/files")
(when-not (or (dnd/from-child? e) (do
(dom/prevent-default e)
(when-not (or (dnd/from-child? e)
(dnd/broken-event? e)) (dnd/broken-event? e))
(when (not= selected-project project-id) (when (not= selected-project project-id)
(reset! dragging? true)))) (reset! dragging? true))))
(when (or (dnd/has-type? e "Files") (or (dnd/has-type? e "Files")
(dnd/has-type? e "application/x-moz-file")) (dnd/has-type? e "application/x-moz-file"))
(dom/prevent-default e) (do
(reset! dragging? true)))) (dom/prevent-default e)
(reset! dragging? true)))))
on-drag-over on-drag-over
(mf/use-fn (mf/use-fn
@ -531,19 +534,22 @@
(mf/use-fn (mf/use-fn
(mf/deps files selected-files) (mf/deps files selected-files)
(fn [e] (fn [e]
(when (or (dnd/has-type? e "Files") (cond
(dnd/has-type? e "application/x-moz-file")) (dnd/has-type? e "penpot/files")
(dom/prevent-default e) (do
(reset! dragging? false) (reset! dragging? false)
(import-files (.-files (.-dataTransfer e)))) (when (not= selected-project project-id)
(let [data {:ids (into #{} (keys selected-files))
:project-id project-id}
mdata {:on-success on-drop-success}]
(st/emit! (dd/move-files (with-meta data mdata))))))
(when (dnd/has-type? e "penpot/files") (or (dnd/has-type? e "Files")
(reset! dragging? false) (dnd/has-type? e "application/x-moz-file"))
(when (not= selected-project project-id) (do
(let [data {:ids (into #{} (keys selected-files)) (dom/prevent-default e)
:project-id project-id} (reset! dragging? false)
mdata {:on-success on-drop-success}] (import-files (.-files (.-dataTransfer e)))))))]
(st/emit! (dd/move-files (with-meta data mdata))))))))]
[:div.dashboard-grid {:on-drag-enter on-drag-enter [:div.dashboard-grid {:on-drag-enter on-drag-enter
:on-drag-over on-drag-over :on-drag-over on-drag-over