The js/confirm function is undefined when in the convert-options helper function in the com.fulcrologic.rad.form namespace, and so the confirmation function does not work by default when trying to leave a form. This was noted by @tylernisonoff in https://clojurians-log.clojureverse.org/fulcro/2020-08-10/1597018953.191600 and the observations in the message are still valid with regards to the js/alert function being defined but not the js/confirm until we set again the ::form/confirm option in the form component definition with #?(:cljs js/confirm).
Based on what I could understand and test/experiment/find, the js/confirm var/declaration is being shadowed by the local confirm variable set by the when-let. A better/more detailed explanation of the problem can be found at https://gist.github.com/pesterhazy/2bd06fc6e12686e0705763988099b3c5.
This PR suggests changing the function/symbol name from confirm to confirm-fn to avoid this problem.
To reproduce the problem:
using the fulcro-rad-demo code
in the browser, navigate to one of the accounts
change a field value without saving the form
try to select one of the other menu items
there won't be any confirmation box asking if we really want to leave the form
Now, using the fulcro-rad repo with the suggested patch repeat the steps 1-4 and the box will popup asking if we want to leave the form and lose the unsaved changes.
The
js/confirm
function is undefined when in theconvert-options
helper function in thecom.fulcrologic.rad.form
namespace, and so the confirmation function does not work by default when trying to leave a form. This was noted by @tylernisonoff in https://clojurians-log.clojureverse.org/fulcro/2020-08-10/1597018953.191600 and the observations in the message are still valid with regards to thejs/alert
function being defined but not thejs/confirm
until we set again the::form/confirm
option in the form component definition with#?(:cljs js/confirm)
.Based on what I could understand and test/experiment/find, the
js/confirm
var/declaration is being shadowed by the localconfirm
variable set by thewhen-let
. A better/more detailed explanation of the problem can be found at https://gist.github.com/pesterhazy/2bd06fc6e12686e0705763988099b3c5.This PR suggests changing the function/symbol name from
confirm
toconfirm-fn
to avoid this problem.To reproduce the problem:
Now, using the fulcro-rad repo with the suggested patch repeat the steps 1-4 and the box will popup asking if we want to leave the form and lose the unsaved changes.