When using a callback for choices, and if something within that function should react to changes, the choices fn won't rerun leading to out of sync choices.
Example
(defn uom-drop-down
[{:keys [uoms
model
update-fn
create-fn]}]
[:div
[:p (str "Total UOMS: " (count uoms))] ;; <- This updates fine
[single-dropdown
:src (at)
:width "150px"
:filter-box? true
:auto-complete? true
:model model
:label-fn (fn [val] (:label val))
:id-fn (fn [val] val)
:debounce-delay 0
:on-change (fn [val]
(case (:type val)
:create (create-fn (:val val))
:select (update-fn [(:id val) val])))
:choices (fn [{:keys [filter-text]} done _] ;; <- This never gets recalled even if uoms changes
(let [results (query->suggestions uoms :label filter-text)]
(done (if (seq results)
results
[{:label (str "No match found. Create " filter-text) :val filter-text :type :create}]))))]])
uoms is getting passed in from the parent. If there is no match, we want to be able to create a new UOM and then have that be added to the list for future use. Currently this choices won't rerun if uoms is updated.
Any help on how I might get this to work much appreciated.
Hi,
When using a callback for choices, and if something within that function should react to changes, the choices fn won't rerun leading to out of sync choices.
Example
uoms is getting passed in from the parent. If there is no match, we want to be able to create a new UOM and then have that be added to the list for future use. Currently this choices won't rerun if uoms is updated.
Any help on how I might get this to work much appreciated.
Thank you