diff --git a/src/cljs/ataru/application_common/application_field_common.cljs b/src/cljs/ataru/application_common/application_field_common.cljs index 7e85bbe3a7..ae271964ff 100644 --- a/src/cljs/ataru/application_common/application_field_common.cljs +++ b/src/cljs/ataru/application_common/application_field_common.cljs @@ -77,22 +77,27 @@ (let [collapsed (reagent/atom true) scroll-height (reagent/atom nil) listener (reagent/atom nil) + mounted? (reagent/atom false) timeout (atom nil) debounced-resize (fn [component] (js/clearTimeout @timeout) (reset! timeout - (js/setTimeout #(set-markdown-height component scroll-height) 200))) + (js/setTimeout (fn [] + (when @mounted? + (set-markdown-height component scroll-height))) 200))) lang (re-frame/subscribe [:application/form-language])] (reagent/create-class {:component-did-mount (fn [component] + (reset! mounted? true) (set-markdown-height component scroll-height) (reset! listener #(debounced-resize component)) (.addEventListener js/window "resize" @listener)) :component-will-unmount (fn [_] + (reset! mounted? false) (.removeEventListener js/window "resize" @listener)) :component-did-update