Adjusted chat input to send text on on-submit-editing

Signed-off-by: Volodymyr Kozieiev <vkjr.sp@gmail.com>
This commit is contained in:
Volodymyr Kozieiev 2018-10-25 10:35:45 +03:00
parent f8ef431373
commit 0bc9fb6d9d
No known key found for this signature in database
GPG Key ID: 1F706640AAF07516
1 changed files with 4 additions and 9 deletions

View File

@ -327,15 +327,10 @@
:ref #(reset! inp-ref %)
:default-value input-text
:on-content-size-change #(set-container-height-fn (.-height (.-contentSize (.-nativeEvent %))))
:on-key-press (fn [e]
(let [native-event (.-nativeEvent e)
key (.-key native-event)
modifiers (js->clj (.-modifiers native-event))
should-send (and (= key "Enter") (not (contains? (set modifiers) "shift")))]
(when should-send
(.clear @inp-ref)
(.focus @inp-ref)
(re-frame/dispatch [:chat.ui/send-current-message]))))
:submit-shortcut {:key "Enter"}
:on-submit-editing #(do (.clear @inp-ref)
(.focus @inp-ref)
(re-frame/dispatch [:chat.ui/send-current-message]))
:on-change (fn [e]
(let [native-event (.-nativeEvent e)
text (.-text native-event)]