From a86f198406958f8c9dd25c90d5f2fd692a48ef17 Mon Sep 17 00:00:00 2001 From: Andrey Antukh Date: Thu, 22 Oct 2020 13:11:15 +0200 Subject: [PATCH] :bug: Fix scrollbar on comment thread. --- .../main/partials/workspace-comments.scss | 5 ++-- .../src/app/main/ui/workspace/comments.cljs | 26 ++++++++++++------- 2 files changed, 19 insertions(+), 12 deletions(-) diff --git a/frontend/resources/styles/main/partials/workspace-comments.scss b/frontend/resources/styles/main/partials/workspace-comments.scss index 21d7169bb4..6c51747747 100644 --- a/frontend/resources/styles/main/partials/workspace-comments.scss +++ b/frontend/resources/styles/main/partials/workspace-comments.scss @@ -57,6 +57,7 @@ .comments { max-height: 320px; + overflow-y: auto; } hr { @@ -205,8 +206,8 @@ .comment-options-dropdown { - top: 0px; - right: -160px; + top: 7px; + right: 7px; width: 150px; border: 1px solid #B1B2B5; diff --git a/frontend/src/app/main/ui/workspace/comments.cljs b/frontend/src/app/main/ui/workspace/comments.cljs index 8c953b9bae..8e73260982 100644 --- a/frontend/src/app/main/ui/workspace/comments.cljs +++ b/frontend/src/app/main/ui/workspace/comments.cljs @@ -197,13 +197,20 @@ (mf/defc comment-item [{:keys [comment thread] :as props}] (let [profile (get @refs/workspace-users (:owner-id comment)) - options? (mf/use-state false) + + options (mf/use-state false) edition? (mf/use-state false) + on-show-options + (mf/use-callback #(reset! options true)) + + on-hide-options + (mf/use-callback #(reset! options false)) + on-edit-clicked (mf/use-callback (fn [] - (reset! options? false) + (reset! options false) (reset! edition? true))) on-delete-comment @@ -259,7 +266,7 @@ [:span i/checkbox-unchecked])]) [:div.options - [:div.options-icon {:on-click #(swap! options? not)} i/actions]]] + [:div.options-icon {:on-click on-show-options} i/actions]]] [:div.content (if @edition? @@ -268,8 +275,8 @@ :on-cancel on-cancel}] [:span.text (:content comment)])]] - [:& dropdown {:show @options? - :on-close identity} + [:& dropdown {:show @options + :on-close on-hide-options} [:ul.dropdown.comment-options-dropdown [:li {:on-click on-edit-clicked} "Edit"] (if thread @@ -277,8 +284,8 @@ [:li {:on-click on-delete-comment} "Delete comment"])]]])) (defn comments-ref - [thread-id] - (l/derived (l/in [:comments thread-id]) st/state)) + [{:keys [id] :as thread}] + (l/derived (l/in [:comments id]) st/state)) (mf/defc thread-comments [{:keys [thread zoom]}] @@ -287,12 +294,11 @@ pos-x (+ (* (:x pos) zoom) 14) pos-y (- (* (:y pos) zoom) 14) - - comments-ref (mf/use-memo (mf/deps (:id thread)) #(comments-ref (:id thread))) + comments-ref (mf/use-memo (mf/deps thread) #(comments-ref thread)) comments-map (mf/deref comments-ref) comments (->> (vals comments-map) (sort-by :created-at)) - comment (first comments)] + comment (first comments)] (mf/use-effect (st/emitf (dwcm/update-comment-thread-status thread)))