Skip to content

Commit

Permalink
only update display-value if the prop's value has actually changed
Browse files Browse the repository at this point in the history
  • Loading branch information
rafd committed Dec 15, 2014
1 parent 5ae4ebf commit b0f19fd
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/om_fields/text.cljs
Expand Up @@ -44,11 +44,12 @@
(did-mount [_]
(when multi-line (auto-resize (om/get-node owner "textarea"))))

; update display-value if the actual value is changed by something else
; update display-value if the actual value is changed elsewhere
om/IWillReceiveProps
(will-receive-props [_ next-props]
(om/set-state! owner :state "start")
(om/set-state! owner :display-value (value-to-string (get-in next-props edit-key))))
(when (not= (get-in next-props edit-key) (get-in (om/get-props owner) edit-key))
(om/set-state! owner :state "start")
(om/set-state! owner :display-value (value-to-string (get-in next-props edit-key)))))

om/IRenderState
(render-state [_ state]
Expand Down

0 comments on commit b0f19fd

Please sign in to comment.