Procházet zdrojové kódy

chore: clear state

Tienson Qin před 2 roky
rodič
revize
fad6dfca11

+ 7 - 3
src/main/frontend/components/property.cljs

@@ -373,6 +373,10 @@
 
 (rum/defcs property-input < rum/reactive
   (rum/local false ::show-new-property-config?)
+  {:will-unmount (fn [state]
+                   (when-let [*property-key (nth (:rum/args state) 1)]
+                     (reset! *property-key nil))
+                   state)}
   shortcut/disable-all-shortcuts
   [state entity *property-key *property-value {:keys [class-schema? _page-configure? in-block-container?]
                                                :as opts}]
@@ -458,11 +462,11 @@
                 (not (:in-block-container? opts)))
            [:a.fade-link.flex.add-property
             {:on-click (fn []
+                         (reset! *property-key nil)
+                         (reset! *property-value nil)
                          (state/set-state! :editor/block block)
                          (state/set-state! :editor/properties-container id)
-                         (reset! *new-property? true)
-                         (reset! *property-key nil)
-                         (reset! *property-value nil))}
+                         (reset! *new-property? true))}
             [:div.flex.flex-row.items-center {:style {:padding-left 1}}
              (ui/icon "plus" {:size 15})
              [:div.ml-1.text-sm {:style {:padding-left 2}} "Add property"]]]

+ 2 - 1
src/main/frontend/components/property/value.cljs

@@ -344,7 +344,8 @@
            esc? (= (util/ekey e) "Escape")
            backspace? (= (util/ekey e) "Backspace")
            new-value (util/evalue e)
-           new-property? (:editor/properties-container @state/state)]
+           new-property? (or @(:editor/properties-container @state/state)
+                             @(:editor/new-property-input-id @state/state))]
        (when (and (or enter? esc? backspace?)
                   (not (state/get-editor-action)))
          (when-not backspace? (util/stop e))