mirror of
https://github.com/penpot/penpot.git
synced 2025-12-11 22:14:05 +01:00
🐛 Fix input confirmation behavior is not uniform
This commit is contained in:
@@ -25,6 +25,7 @@
|
|||||||
- Fix search shortcut [Taiga #10265](https://tree.taiga.io/project/penpot/issue/10265)
|
- Fix search shortcut [Taiga #10265](https://tree.taiga.io/project/penpot/issue/10265)
|
||||||
- Fix shortcut conflict in text editor (increase/decrease font size vs word selection)
|
- Fix shortcut conflict in text editor (increase/decrease font size vs word selection)
|
||||||
- Fix problem with plugins generating code for pages different than current one [Taiga #12312](https://tree.taiga.io/project/penpot/issue/12312)
|
- Fix problem with plugins generating code for pages different than current one [Taiga #12312](https://tree.taiga.io/project/penpot/issue/12312)
|
||||||
|
- Fix input confirmation behavior is not uniform [Taiga #12294](https://tree.taiga.io/project/penpot/issue/12294)
|
||||||
|
|
||||||
## 2.11.0 (Unreleased)
|
## 2.11.0 (Unreleased)
|
||||||
|
|
||||||
|
|||||||
@@ -70,7 +70,7 @@
|
|||||||
:default-value value
|
:default-value value
|
||||||
:on-key-up on-key-up
|
:on-key-up on-key-up
|
||||||
:max-length max-input-length
|
:max-length max-input-length
|
||||||
:on-blur cancel-edition}]
|
:on-blur accept-edition}]
|
||||||
|
|
||||||
[:span {:class [(stl/css :editable-label-text) class-label]
|
[:span {:class [(stl/css :editable-label-text) class-label]
|
||||||
:title tooltip}
|
:title tooltip}
|
||||||
|
|||||||
@@ -202,7 +202,9 @@
|
|||||||
dom/get-value)]
|
dom/get-value)]
|
||||||
(reset! selected-id* value)
|
(reset! selected-id* value)
|
||||||
(reset! filter-id* value)
|
(reset! filter-id* value)
|
||||||
(reset! focused-id* nil))))
|
(reset! focused-id* nil)
|
||||||
|
(when (fn? on-change)
|
||||||
|
(on-change value)))))
|
||||||
|
|
||||||
selected-option
|
selected-option
|
||||||
(mf/with-memo [options selected-id]
|
(mf/with-memo [options selected-id]
|
||||||
|
|||||||
@@ -25,20 +25,25 @@
|
|||||||
(mf/defc input-with-meta*
|
(mf/defc input-with-meta*
|
||||||
{::mf/schema schema:input-with-meta}
|
{::mf/schema schema:input-with-meta}
|
||||||
[{:keys [value meta max-length is-editing on-blur] :rest props}]
|
[{:keys [value meta max-length is-editing on-blur] :rest props}]
|
||||||
(let [editing* (mf/use-state (d/nilv is-editing false))
|
(let [title (if meta (str value ": " meta) value)
|
||||||
editing? (deref editing*)
|
editing* (mf/use-state (d/nilv is-editing false))
|
||||||
|
editing? (deref editing*)
|
||||||
|
input-ref (mf/use-ref)
|
||||||
|
last-node* (mf/use-ref nil)
|
||||||
|
|
||||||
input-ref (mf/use-ref)
|
ref-cb (mf/use-fn
|
||||||
input (mf/ref-val input-ref)
|
(fn [node]
|
||||||
|
;; We need to keep the last not-null node for cleanup
|
||||||
title (if meta (str value ": " meta) value)
|
(mf/set-ref-val! input-ref node)
|
||||||
|
(when node
|
||||||
|
(mf/set-ref-val! last-node* node))))
|
||||||
|
|
||||||
on-edit
|
on-edit
|
||||||
(mf/use-fn
|
(mf/use-fn
|
||||||
(fn [event]
|
(fn [event]
|
||||||
(dom/stop-propagation event)
|
(dom/stop-propagation event)
|
||||||
(reset! editing* true)
|
(reset! editing* true)
|
||||||
(dom/focus! input)))
|
(dom/focus! (mf/ref-val input-ref))))
|
||||||
|
|
||||||
on-stop-edit
|
on-stop-edit
|
||||||
(mf/use-fn
|
(mf/use-fn
|
||||||
@@ -64,7 +69,7 @@
|
|||||||
(when ^boolean enter? (dom/blur! node))
|
(when ^boolean enter? (dom/blur! node))
|
||||||
(when ^boolean esc? (dom/blur! node)))))
|
(when ^boolean esc? (dom/blur! node)))))
|
||||||
|
|
||||||
props (mf/spread-props props {:ref input-ref
|
props (mf/spread-props props {:ref ref-cb
|
||||||
:default-value value
|
:default-value value
|
||||||
:max-length (d/nilv max-length max-input-length)
|
:max-length (d/nilv max-length max-input-length)
|
||||||
:auto-focus true
|
:auto-focus true
|
||||||
@@ -72,6 +77,18 @@
|
|||||||
:on-blur on-stop-edit
|
:on-blur on-stop-edit
|
||||||
:on-key-down handle-key-down})]
|
:on-key-down handle-key-down})]
|
||||||
|
|
||||||
|
;; Cleanup: Simulate a blur event
|
||||||
|
(mf/with-effect [on-blur last-node*]
|
||||||
|
(fn []
|
||||||
|
(let [input (mf/ref-val last-node*)
|
||||||
|
fake-blur-event #js {:type "blur"
|
||||||
|
:target input
|
||||||
|
:currentTarget input
|
||||||
|
:stopPropagation (fn [])
|
||||||
|
:preventDefault (fn [])}]
|
||||||
|
(when input
|
||||||
|
(on-blur fake-blur-event)))))
|
||||||
|
|
||||||
(if editing?
|
(if editing?
|
||||||
[:div {:class (stl/css :input-with-meta-edit-container)}
|
[:div {:class (stl/css :input-with-meta-edit-container)}
|
||||||
[:> input* props]]
|
[:> input* props]]
|
||||||
|
|||||||
Reference in New Issue
Block a user