🐛 Fix issue with annotation menu rerendering (2)

This commit is contained in:
Pablo Alba 2024-06-07 13:08:32 +02:00
parent b170a619cd
commit f052c81ee1

View file

@ -86,37 +86,37 @@
(mf/deps adjust-textarea-size creating?) (mf/deps adjust-textarea-size creating?)
(fn [event] (fn [event]
(dom/stop-propagation event) (dom/stop-propagation event)
(rerender-fn)
(when-let [textarea (mf/ref-val textarea-ref)] (when-let [textarea (mf/ref-val textarea-ref)]
(dom/set-value! textarea annotation) (dom/set-value! textarea annotation)
(reset! editing* false) (reset! editing* false)
(when creating? (when creating?
(st/emit! (dw/set-annotations-id-for-create nil))) (st/emit! (dw/set-annotations-id-for-create nil)))
(adjust-textarea-size)))) (adjust-textarea-size)
(rerender-fn))))
on-edit on-edit
(mf/use-fn (mf/use-fn
(fn [event] (fn [event]
(dom/stop-propagation event) (dom/stop-propagation event)
(rerender-fn)
(when ^boolean main-instance? (when ^boolean main-instance?
(when-let [textarea (mf/ref-val textarea-ref)] (when-let [textarea (mf/ref-val textarea-ref)]
(reset! editing* true) (reset! editing* true)
(dom/focus! textarea))))) (dom/focus! textarea)
(rerender-fn)))))
on-save on-save
(mf/use-fn (mf/use-fn
(mf/deps creating?) (mf/deps creating?)
(fn [event] (fn [event]
(dom/stop-propagation event) (dom/stop-propagation event)
(rerender-fn)
(when-let [textarea (mf/ref-val textarea-ref)] (when-let [textarea (mf/ref-val textarea-ref)]
(let [text (dom/get-value textarea)] (let [text (dom/get-value textarea)]
(when-not (str/blank? text) (when-not (str/blank? text)
(reset! editing* false) (reset! editing* false)
(st/emit! (dw/update-component-annotation component-id text)) (st/emit! (dw/update-component-annotation component-id text))
(when ^boolean creating? (when ^boolean creating?
(st/emit! (dw/set-annotations-id-for-create nil)))))))) (st/emit! (dw/set-annotations-id-for-create nil)))
(rerender-fn))))))
on-delete-annotation on-delete-annotation
(mf/use-fn (mf/use-fn
@ -124,12 +124,12 @@
(fn [event] (fn [event]
(dom/stop-propagation event) (dom/stop-propagation event)
(let [on-accept (fn [] (let [on-accept (fn []
(rerender-fn)
(st/emit! (st/emit!
;; (ptk/data-event {::ev/name "delete-component-annotation"}) ;; (ptk/data-event {::ev/name "delete-component-annotation"})
(when creating? (when creating?
(dw/set-annotations-id-for-create nil)) (dw/set-annotations-id-for-create nil))
(dw/update-component-annotation component-id nil)))] (dw/update-component-annotation component-id nil)
(rerender-fn)))]
(st/emit! (modal/show (st/emit! (modal/show
{:type :confirm {:type :confirm
:title (tr "modals.delete-component-annotation.title") :title (tr "modals.delete-component-annotation.title")