Skip to content

Commit 06e59b9

Browse files
authored
Add cache busting to inputs
1 parent 18469d9 commit 06e59b9

File tree

1 file changed

+10
-7
lines changed

1 file changed

+10
-7
lines changed

src/main/com/fulcrologic/fulcro/dom/inputs.cljc

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -35,25 +35,28 @@
3535
(let [{:keys [value onChange]} (comp/props this)
3636
nsv (evt/target-value evt)
3737
nv (string->model nsv)]
38-
(comp/set-state! this {:stringValue nsv
39-
:oldPropValue value
40-
:value nv})
38+
(comp/set-state! this {:stringValue nsv
39+
:oldPropValue value
40+
:cacheValue nv
41+
:cacheInvalid? false})
4142
(when (and onChange (not= value nv))
4243
(onChange nv))))
43-
:stringValue (model->string value)}]
44+
:stringValue (model->string value)
45+
:cacheInvalid? true}]
4446
(set! (.-state this) (cljs.core/js-obj "fulcro$state" initial-state)))
4547
nil)))]
4648
(comp/configure-component! cls kw
4749
{:getDerivedStateFromProps
4850
(fn [latest-props state]
4951
(let [{:keys [value]} latest-props
50-
{:keys [oldPropValue stringValue]} state
51-
ignorePropValue? (or (= oldPropValue value) (= value (:value state)))
52+
{:keys [oldPropValue stringValue cacheValue cacheInvalid?]} state
53+
ignorePropValue? (or (= oldPropValue value) (when-not cacheInvalid? (= value cacheValue)))
54+
cacheInvalid? (or cacheInvalid? ignorePropValue?)
5255
stringValue (cond-> (if ignorePropValue?
5356
stringValue
5457
(model->string value))
5558
string-filter string-filter)
56-
new-derived-state (merge state {:stringValue stringValue :oldPropValue value})]
59+
new-derived-state (merge state {:stringValue stringValue :oldPropValue value :cacheInvalid? cacheInvalid?})]
5760
#js {"fulcro$state" new-derived-state}))
5861
:render
5962
(fn [this]

0 commit comments

Comments
 (0)