Fork me on GitHub
#fulcro
<
2022-09-17
>
thosmos17:09:55

I just returned to a fulcro project after a year away, updated to the latest stable version, and was thrilled to find it build and run great! However, the problem I’m seeing is still present: I’m having an issue with a :decimal Rad semantic-ui form field that won’t accept a negative value. When the “-” is entered, the cursor jumps to the end of the field. Anyone else seen this? I’m using the default renderer from : decimal-field/render-field If I use the :USD renderer, then the minus shows, so it appears to be a problem with the default decimal renderer. UPDATE: it looks like the problem is the :string-filter in the default decimal renderer. If I remove the replace, like the :USD , then it works

(def ui-decimal-input
  (comp/factory (inputs/StringBufferedInput ::DecimalInput
                  {:model->string (fn [n] (math/numeric->str n))
                   :string->model (fn [s] (math/numeric s))
                   :string-filter (fn [s] (str/replace s #"[^\d.]" ""))})))
FIXED:
:string-filter (fn [s] (first (re-find #"^-?\d*(\.\d*)?" s)))
I submitted a [PR](https://github.com/fulcrologic/fulcro-rad-semantic-ui/pull/27)

👍 1
❤️ 1
lilactown19:09:36

xposting because I think this might be used by Fulcro? https://clojurians.slack.com/archives/CE08R3QAU/p1663429274159529