From d854398dae4a444de2cdeb7823bd9922e49da005 Mon Sep 17 00:00:00 2001 From: "alonso.torres" Date: Tue, 28 Jan 2025 16:00:09 +0100 Subject: [PATCH] :bug: Disale button on empty comments --- frontend/src/app/main/ui/comments.cljs | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/frontend/src/app/main/ui/comments.cljs b/frontend/src/app/main/ui/comments.cljs index c1797338d..a9761d9e5 100644 --- a/frontend/src/app/main/ui/comments.cljs +++ b/frontend/src/app/main/ui/comments.cljs @@ -122,6 +122,13 @@ (d/seek (fn [[it _]] (= node it))) (second))) +(defn- blank-content? + [content] + (or (str/blank? content) + (str/empty? content) + ;; If only one char and it's the zero-width whitespace + (and (= 1 (count content)) (= (first content) \u200B)))) + ;; Component that renders the component content (mf/defc comment-content* {::mf/private true} @@ -602,8 +609,7 @@ (let [show-buttons? (mf/use-state false) content (mf/use-state "") - disabled? (or (str/blank? @content) - (str/empty? @content)) + disabled? (blank-content? @content) on-focus (mf/use-fn @@ -664,8 +670,7 @@ (mf/deps @content) (fn [] (on-submit @content))) - disabled? (or (str/blank? @content) - (str/empty? @content))] + disabled? (blank-content? @content)] [:div {:class (stl/css :form)} [:> comment-input* @@ -698,8 +703,7 @@ pos-x (* (:x position) zoom) pos-y (* (:y position) zoom) - disabled? (or (str/blank? content) - (str/empty? content)) + disabled? (blank-content? content) on-esc (mf/use-fn