0
Fork 0
mirror of https://github.com/penpot/penpot.git synced 2025-01-10 08:50:57 -05:00

🐛 Fix problem with numeric inputs

This commit is contained in:
alonso.torres 2024-02-07 12:59:41 +01:00
parent 3d66ae21de
commit 84537b607e

View file

@ -191,15 +191,15 @@
(mf/use-fn (mf/use-fn
(mf/deps parse-value apply-value update-input on-blur) (mf/deps parse-value apply-value update-input on-blur)
(fn [event] (fn [event]
(let [new-value (or @last-value* default)] (when (mf/ref-val dirty-ref)
(if (or nillable? new-value) (let [new-value (or @last-value* default)]
(apply-value event new-value) (if (or nillable? new-value)
(update-input new-value))) (apply-value event new-value)
(when (fn? on-blur) (update-input new-value)))
(on-blur event)))) (when (fn? on-blur)
(on-blur event)))))
handle-unmount handle-unmount (h/use-ref-callback handle-blur)
(h/use-ref-callback handle-blur)
on-click on-click
(mf/use-fn (mf/use-fn
@ -240,10 +240,7 @@
(when-let [input-node (mf/ref-val ref)] (when-let [input-node (mf/ref-val ref)]
(dom/set-value! input-node (fmt/format-number value)))) (dom/set-value! input-node (fmt/format-number value))))
(mf/with-effect [] (mf/with-effect [handle-unmount] handle-unmount)
(fn []
(when (mf/ref-val dirty-ref)
(handle-unmount))))
(mf/with-layout-effect [] (mf/with-layout-effect []
(let [keys [(events/listen globals/window "pointerdown" on-click) (let [keys [(events/listen globals/window "pointerdown" on-click)