mirror of
https://github.com/penpot/penpot.git
synced 2025-02-01 11:59:17 -05:00
Refocus input on token deletion
This commit is contained in:
parent
86b493522c
commit
2efd6e1584
1 changed files with 7 additions and 2 deletions
|
@ -70,6 +70,7 @@
|
||||||
:bottom nil})
|
:bottom nil})
|
||||||
state (deref state*)
|
state (deref state*)
|
||||||
is-open? (:is-open? state)
|
is-open? (:is-open? state)
|
||||||
|
refocus? (:refocus? state)
|
||||||
current-value (:current-value state)
|
current-value (:current-value state)
|
||||||
element-id (:id state)
|
element-id (:id state)
|
||||||
|
|
||||||
|
@ -142,7 +143,8 @@
|
||||||
(cond
|
(cond
|
||||||
(and backspace? caret-at-beginning?) (do
|
(and backspace? caret-at-beginning?) (do
|
||||||
(dom/prevent-default event)
|
(dom/prevent-default event)
|
||||||
(on-token-remove token))
|
(on-token-remove token)
|
||||||
|
(swap! state* assoc :refocus? true)
|
||||||
:else (set-token-value! value))
|
:else (set-token-value! value))
|
||||||
(js/console.log "backspace?" caret-at-beginning? (.. event -target)))
|
(js/console.log "backspace?" caret-at-beginning? (.. event -target)))
|
||||||
is-open? (let [up? (kbd/up-arrow? event)
|
is-open? (let [up? (kbd/up-arrow? event)
|
||||||
|
@ -157,6 +159,8 @@
|
||||||
handle-focus
|
handle-focus
|
||||||
(mf/use-fn
|
(mf/use-fn
|
||||||
(fn []
|
(fn []
|
||||||
|
(when refocus?
|
||||||
|
(swap! state* dissoc :refocus?))
|
||||||
(mf/set-ref-val! emit-blur? false)))
|
(mf/set-ref-val! emit-blur? false)))
|
||||||
|
|
||||||
handle-blur
|
handle-blur
|
||||||
|
@ -202,7 +206,8 @@
|
||||||
:on-focus handle-focus
|
:on-focus handle-focus
|
||||||
:on-blur handle-blur
|
:on-blur handle-blur
|
||||||
:type type}]
|
:type type}]
|
||||||
(= type "number") [:> numeric-input* {:value (or current-value "")
|
(= type "number") [:> numeric-input* {:autoFocus refocus?
|
||||||
|
:value (or current-value "")
|
||||||
:className input-class
|
:className input-class
|
||||||
:on-change set-value
|
:on-change set-value
|
||||||
:on-focus handle-focus
|
:on-focus handle-focus
|
||||||
|
|
Loading…
Add table
Reference in a new issue