mirror of
https://github.com/penpot/penpot.git
synced 2025-01-11 01:10:28 -05:00
🐛 Fix comment reply menu
This commit is contained in:
parent
193df9ce1e
commit
411af023d5
3 changed files with 29 additions and 8 deletions
|
@ -67,6 +67,7 @@
|
||||||
(update :comment-threads assoc id (dissoc thread :comment))
|
(update :comment-threads assoc id (dissoc thread :comment))
|
||||||
(update-in [:workspace-data :pages-index page-id :options :comment-threads-position] assoc id position)
|
(update-in [:workspace-data :pages-index page-id :options :comment-threads-position] assoc id position)
|
||||||
(update :comments-local assoc :open id)
|
(update :comments-local assoc :open id)
|
||||||
|
(update :comments-local assoc :options nil)
|
||||||
(update :comments-local dissoc :draft)
|
(update :comments-local dissoc :draft)
|
||||||
(update :workspace-drawing dissoc :comment)
|
(update :workspace-drawing dissoc :comment)
|
||||||
(update-in [:comments id] assoc (:id comment) comment))))
|
(update-in [:comments id] assoc (:id comment) comment))))
|
||||||
|
@ -120,6 +121,7 @@
|
||||||
(update :comment-threads assoc id (dissoc thread :comment))
|
(update :comment-threads assoc id (dissoc thread :comment))
|
||||||
(update-in [:viewer :pages page-id :options :comment-threads-position] assoc id position)
|
(update-in [:viewer :pages page-id :options :comment-threads-position] assoc id position)
|
||||||
(update :comments-local assoc :open id)
|
(update :comments-local assoc :open id)
|
||||||
|
(update :comments-local assoc :options nil)
|
||||||
(update :comments-local dissoc :draft)
|
(update :comments-local dissoc :draft)
|
||||||
(update :workspace-drawing dissoc :comment)
|
(update :workspace-drawing dissoc :comment)
|
||||||
(update-in [:comments id] assoc (:id comment) comment))))
|
(update-in [:comments id] assoc (:id comment) comment))))
|
||||||
|
@ -427,6 +429,7 @@
|
||||||
(update [_ state]
|
(update [_ state]
|
||||||
(-> state
|
(-> state
|
||||||
(update :comments-local assoc :open id)
|
(update :comments-local assoc :open id)
|
||||||
|
(update :comments-local assoc :options nil)
|
||||||
(update :workspace-drawing dissoc :comment)))))
|
(update :workspace-drawing dissoc :comment)))))
|
||||||
|
|
||||||
(defn close-thread
|
(defn close-thread
|
||||||
|
@ -435,7 +438,7 @@
|
||||||
ptk/UpdateEvent
|
ptk/UpdateEvent
|
||||||
(update [_ state]
|
(update [_ state]
|
||||||
(-> state
|
(-> state
|
||||||
(update :comments-local dissoc :open :draft)
|
(update :comments-local dissoc :open :draft :options)
|
||||||
(update :workspace-drawing dissoc :comment)))))
|
(update :workspace-drawing dissoc :comment)))))
|
||||||
|
|
||||||
(defn update-filters
|
(defn update-filters
|
||||||
|
@ -490,6 +493,19 @@
|
||||||
(d/update-in-when [:workspace-drawing :comment] merge data)
|
(d/update-in-when [:workspace-drawing :comment] merge data)
|
||||||
(d/update-in-when [:comments-local :draft] merge data)))))
|
(d/update-in-when [:comments-local :draft] merge data)))))
|
||||||
|
|
||||||
|
(defn toggle-comment-options
|
||||||
|
[comment]
|
||||||
|
(ptk/reify ::toggle-comment-options
|
||||||
|
ptk/UpdateEvent
|
||||||
|
(update [_ state]
|
||||||
|
(update-in state [:comments-local :options] #(if (= (:id comment) %) nil (:id comment))))))
|
||||||
|
|
||||||
|
(defn hide-comment-options
|
||||||
|
[]
|
||||||
|
(ptk/reify ::hide-comment-options
|
||||||
|
ptk/UpdateEvent
|
||||||
|
(update [_ state]
|
||||||
|
(update-in state [:comments-local :options] (constantly nil)))))
|
||||||
|
|
||||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||||
;; Helpers
|
;; Helpers
|
||||||
|
|
|
@ -27,6 +27,8 @@
|
||||||
[okulary.core :as l]
|
[okulary.core :as l]
|
||||||
[rumext.v2 :as mf]))
|
[rumext.v2 :as mf]))
|
||||||
|
|
||||||
|
(def comments-local-options (l/derived :options refs/comments-local))
|
||||||
|
|
||||||
(mf/defc resizing-textarea
|
(mf/defc resizing-textarea
|
||||||
{::mf/wrap-props false}
|
{::mf/wrap-props false}
|
||||||
[props]
|
[props]
|
||||||
|
@ -248,25 +250,28 @@
|
||||||
[{:keys [comment thread users origin] :as props}]
|
[{:keys [comment thread users origin] :as props}]
|
||||||
(let [owner (get users (:owner-id comment))
|
(let [owner (get users (:owner-id comment))
|
||||||
profile (mf/deref refs/profile)
|
profile (mf/deref refs/profile)
|
||||||
options (mf/use-state false)
|
options (mf/deref comments-local-options)
|
||||||
edition? (mf/use-state false)
|
edition? (mf/use-state false)
|
||||||
|
|
||||||
on-toggle-options
|
on-toggle-options
|
||||||
(mf/use-fn
|
(mf/use-fn
|
||||||
|
(mf/deps options)
|
||||||
(fn [event]
|
(fn [event]
|
||||||
(dom/stop-propagation event)
|
(dom/stop-propagation event)
|
||||||
(swap! options not)))
|
(st/emit! (dcm/toggle-comment-options comment))))
|
||||||
|
|
||||||
on-hide-options
|
on-hide-options
|
||||||
(mf/use-fn
|
(mf/use-fn
|
||||||
|
(mf/deps options)
|
||||||
(fn [event]
|
(fn [event]
|
||||||
(dom/stop-propagation event)
|
(dom/stop-propagation event)
|
||||||
(reset! options false)))
|
(st/emit! (dcm/hide-comment-options))))
|
||||||
|
|
||||||
on-edit-clicked
|
on-edit-clicked
|
||||||
(mf/use-fn
|
(mf/use-fn
|
||||||
|
(mf/deps options)
|
||||||
(fn []
|
(fn []
|
||||||
(reset! options false)
|
(st/emit! (dcm/hide-comment-options))
|
||||||
(reset! edition? true)))
|
(reset! edition? true)))
|
||||||
|
|
||||||
on-delete-comment
|
on-delete-comment
|
||||||
|
@ -282,7 +287,6 @@
|
||||||
(dcm/delete-comment-thread-on-viewer thread)
|
(dcm/delete-comment-thread-on-viewer thread)
|
||||||
(dcm/delete-comment-thread-on-workspace thread))))
|
(dcm/delete-comment-thread-on-workspace thread))))
|
||||||
|
|
||||||
|
|
||||||
on-delete-thread
|
on-delete-thread
|
||||||
(mf/use-fn
|
(mf/use-fn
|
||||||
(mf/deps thread)
|
(mf/deps thread)
|
||||||
|
@ -337,7 +341,7 @@
|
||||||
:on-cancel on-cancel}]
|
:on-cancel on-cancel}]
|
||||||
[:span {:class (stl/css :text)} (:content comment)])]]
|
[:span {:class (stl/css :text)} (:content comment)])]]
|
||||||
|
|
||||||
[:& dropdown {:show @options
|
[:& dropdown {:show (= options (:id comment))
|
||||||
:on-close on-hide-options}
|
:on-close on-hide-options}
|
||||||
[:ul {:class (stl/css :comment-options-dropdown)}
|
[:ul {:class (stl/css :comment-options-dropdown)}
|
||||||
[:li {:class (stl/css :context-menu-option)
|
[:li {:class (stl/css :context-menu-option)
|
||||||
|
|
|
@ -216,7 +216,8 @@
|
||||||
.comment-options-dropdown {
|
.comment-options-dropdown {
|
||||||
@extend .dropdown-wrapper;
|
@extend .dropdown-wrapper;
|
||||||
position: absolute;
|
position: absolute;
|
||||||
width: $s-120;
|
width: fit-content;
|
||||||
|
max-width: $s-200;
|
||||||
right: 0;
|
right: 0;
|
||||||
left: unset;
|
left: unset;
|
||||||
.context-menu-option {
|
.context-menu-option {
|
||||||
|
|
Loading…
Reference in a new issue