0
Fork 0
mirror of https://github.com/penpot/penpot.git synced 2025-04-16 08:51:32 -05:00

🐛 Do not allow to create an empty annotation

This commit is contained in:
Pablo Alba 2023-10-30 22:48:50 +01:00 committed by Alonso Torres
parent 0c1f6f8e71
commit 3a1f861303

View file

@ -36,7 +36,7 @@
component-id (:component-id shape)
annotation (:annotation component)
editing? (mf/use-state false)
invalid-text? (mf/use-state (or (nil? annotation)(str/empty? annotation)))
invalid-text? (mf/use-state (or (nil? annotation) (str/blank? annotation)))
size (mf/use-state (count annotation))
textarea-ref (mf/use-ref)
@ -44,7 +44,7 @@
;; based on https://css-tricks.com/the-cleanest-trick-for-autogrowing-textareas/
autogrow #(let [textarea (mf/ref-val textarea-ref)
text (when textarea (.-value textarea))]
(reset! invalid-text? (str/empty? text))
(reset! invalid-text? (str/blank? text))
(when textarea
(reset! size (count text))
(aset (.-dataset (.-parentNode textarea)) "replicatedValue" text)))