r0man / sablono

Lisp/Hiccup style templating for Facebook's React in ClojureScript.
Eclipse Public License 1.0
696 stars 66 forks source link

Checkbox inputs don't update "checked" value on rerender #194

Closed ultimapanzer closed 6 years ago

ultimapanzer commented 6 years ago

Checkbox inputs that are controlled don't update the checked value when it changes.

assume (let [{:keys [checked?]} (om/get-state this)] ....)
[:input {:type "checkbox" :checked checked? :on-change (...)]

(componentDidMount [this]
  (js/setTimeout #(om/update-state! this assoc :checked? true) 1000)

The input's checked status doesn't change. But this one will:

(js/React.createElement "input" #js {:type "checkbox" :checked checked? :onChange (...})
r0man commented 6 years ago

@ultimapanzer Looks like a regression introduced by this: https://github.com/r0man/sablono/commit/d1469ae4b3c1326338fc1e52eaa45d9c0d45c700 I added a test case and a fix for this. Can you try 0.8.4-SNAPSHOT, please?

ultimapanzer commented 6 years ago

This fixes it, thanks! If I'm understanding the change correctly, this feels like a CLJS equivalent of == vs === lol. Thanks again for the rapid response, our team loves this library 👍

r0man commented 6 years ago

Not really == vs ===, but yes, this is a mess :/