Skip to content

Commit

Permalink
Add cache busting to inputs
Browse files Browse the repository at this point in the history
  • Loading branch information
JJ-Atkinson authored May 21, 2024
1 parent 18469d9 commit 06e59b9
Showing 1 changed file with 10 additions and 7 deletions.
17 changes: 10 additions & 7 deletions src/main/com/fulcrologic/fulcro/dom/inputs.cljc
Original file line number Diff line number Diff line change
Expand Up @@ -35,25 +35,28 @@
(let [{:keys [value onChange]} (comp/props this)
nsv (evt/target-value evt)
nv (string->model nsv)]
(comp/set-state! this {:stringValue nsv
:oldPropValue value
:value nv})
(comp/set-state! this {:stringValue nsv
:oldPropValue value
:cacheValue nv
:cacheInvalid? false})
(when (and onChange (not= value nv))
(onChange nv))))
:stringValue (model->string value)}]
:stringValue (model->string value)
:cacheInvalid? true}]
(set! (.-state this) (cljs.core/js-obj "fulcro$state" initial-state)))
nil)))]
(comp/configure-component! cls kw
{:getDerivedStateFromProps
(fn [latest-props state]
(let [{:keys [value]} latest-props
{:keys [oldPropValue stringValue]} state
ignorePropValue? (or (= oldPropValue value) (= value (:value state)))
{:keys [oldPropValue stringValue cacheValue cacheInvalid?]} state
ignorePropValue? (or (= oldPropValue value) (when-not cacheInvalid? (= value cacheValue)))
cacheInvalid? (or cacheInvalid? ignorePropValue?)
stringValue (cond-> (if ignorePropValue?
stringValue
(model->string value))
string-filter string-filter)
new-derived-state (merge state {:stringValue stringValue :oldPropValue value})]
new-derived-state (merge state {:stringValue stringValue :oldPropValue value :cacheInvalid? cacheInvalid?})]
#js {"fulcro$state" new-derived-state}))
:render
(fn [this]
Expand Down

0 comments on commit 06e59b9

Please sign in to comment.