Skip to content

Commit

Permalink
input-zoo: InputSubmitCreate!, renamed from InputSubmitClear!
Browse files Browse the repository at this point in the history
  • Loading branch information
dustingetz committed Sep 23, 2024
1 parent 4267e46 commit 5c502f4
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions src/hyperfiddle/input_zoo0.cljc
Original file line number Diff line number Diff line change
Expand Up @@ -194,8 +194,11 @@

;; Submit and clear inputs - chat, create-new, etc

(e/defn InputSubmitClear! [& {:keys [maxlength type] :as props
:or {maxlength 100 type "text"}}]
(e/defn InputSubmitCreate!
"optimistic, cancel & retry are forwarded to optimistic list item's InputSubmit!
buffers (dirty), commit, discard bundled as enter/esc"
[& {:keys [maxlength type] :as props
:or {maxlength 100 type "text"}}]
(e/client
(dom/input (dom/props (assoc props :maxLength maxlength :type type))
(letfn [(read! [node] (not-empty (subs (.-value node) 0 maxlength)))
Expand All @@ -205,9 +208,8 @@
(= "Enter" k) (read-clear! (.-target e))
(= "Escape" k) (do (set! (.-value dom/node) "") nil)
() nil)))]
(PendingMonitor
(dom/OnAll "keydown" submit!))))))

#_(PendingMonitor) ; the optimistic list item is responsible for pending/retry affordances
(dom/OnAll "keydown" submit!)))))

;; Graveyard

Expand Down

0 comments on commit 5c502f4

Please sign in to comment.