mirror of
https://github.com/penpot/penpot.git
synced 2025-03-11 23:31:21 -05:00
🐛 Avoid numeric inputs to allow big numbers
This commit is contained in:
parent
4909e7861f
commit
134265094c
2 changed files with 30 additions and 29 deletions
|
@ -42,6 +42,7 @@
|
||||||
|
|
||||||
### :bug: Bugs fixed
|
### :bug: Bugs fixed
|
||||||
|
|
||||||
|
- Avoid numeric inputs to allow big numbers [Taiga #2858](https://tree.taiga.io/project/penpot/issue/2858)
|
||||||
- Fix component contex menu size [Taiga #2480](https://tree.taiga.io/project/penpot/issue/2480)
|
- Fix component contex menu size [Taiga #2480](https://tree.taiga.io/project/penpot/issue/2480)
|
||||||
- Add shadow to artboard make it lose the fill [Taiga #3139](https://tree.taiga.io/project/penpot/issue/3139)
|
- Add shadow to artboard make it lose the fill [Taiga #3139](https://tree.taiga.io/project/penpot/issue/3139)
|
||||||
- Avoid numeric inputs to change its value without focusing them [Taiga #3140](https://tree.taiga.io/project/penpot/issue/3140)
|
- Avoid numeric inputs to change its value without focusing them [Taiga #3140](https://tree.taiga.io/project/penpot/issue/3140)
|
||||||
|
|
|
@ -73,44 +73,44 @@
|
||||||
|
|
||||||
parse-value
|
parse-value
|
||||||
(mf/use-callback
|
(mf/use-callback
|
||||||
(mf/deps ref min-val max-val value nillable default-val)
|
(mf/deps ref min-val max-val value nillable default-val)
|
||||||
(fn []
|
(fn []
|
||||||
(let [input-node (mf/ref-val ref)
|
(let [input-node (mf/ref-val ref)
|
||||||
new-value (-> (dom/get-value input-node)
|
new-value (-> (dom/get-value input-node)
|
||||||
(str/strip-suffix ".")
|
(str/strip-suffix ".")
|
||||||
(sm/expr-eval value))]
|
(sm/expr-eval value))]
|
||||||
(cond
|
(cond
|
||||||
(d/num? new-value)
|
(d/num? new-value)
|
||||||
(-> new-value
|
(-> new-value
|
||||||
(cljs.core/max us/min-safe-int)
|
(cljs.core/max (/ us/min-safe-int 2))
|
||||||
(cljs.core/min us/max-safe-int)
|
(cljs.core/min (/ us/max-safe-int 2))
|
||||||
(cond->
|
(cond->
|
||||||
(d/num? min-val)
|
(d/num? min-val)
|
||||||
(cljs.core/max min-val)
|
(cljs.core/max min-val)
|
||||||
|
|
||||||
(d/num? max-val)
|
(d/num? max-val)
|
||||||
(cljs.core/min max-val)))
|
(cljs.core/min max-val)))
|
||||||
|
|
||||||
nillable
|
nillable
|
||||||
default-val
|
default-val
|
||||||
|
|
||||||
:else value))))
|
:else value))))
|
||||||
|
|
||||||
update-input
|
update-input
|
||||||
(mf/use-callback
|
(mf/use-callback
|
||||||
(mf/deps ref)
|
(mf/deps ref)
|
||||||
(fn [new-value]
|
(fn [new-value]
|
||||||
(let [input-node (mf/ref-val ref)]
|
(let [input-node (mf/ref-val ref)]
|
||||||
(dom/set-value! input-node (fmt/format-number new-value)))))
|
(dom/set-value! input-node (fmt/format-number new-value)))))
|
||||||
|
|
||||||
apply-value
|
apply-value
|
||||||
(mf/use-callback
|
(mf/use-callback
|
||||||
(mf/deps on-change update-input value)
|
(mf/deps on-change update-input value)
|
||||||
(fn [new-value]
|
(fn [new-value]
|
||||||
(mf/set-ref-val! dirty-ref false)
|
(mf/set-ref-val! dirty-ref false)
|
||||||
(when (and (not= new-value value) (some? on-change))
|
(when (and (not= new-value value) (some? on-change))
|
||||||
(on-change new-value))
|
(on-change new-value))
|
||||||
(update-input new-value)))
|
(update-input new-value)))
|
||||||
|
|
||||||
set-delta
|
set-delta
|
||||||
(mf/use-callback
|
(mf/use-callback
|
||||||
|
|
Loading…
Add table
Reference in a new issue