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 %) :ref #(reset! inp-ref %)
:default-value input-text :default-value input-text
:on-content-size-change #(set-container-height-fn (.-height (.-contentSize (.-nativeEvent %)))) :on-content-size-change #(set-container-height-fn (.-height (.-contentSize (.-nativeEvent %))))
:on-key-press (fn [e] :submit-shortcut {:key "Enter"}
(let [native-event (.-nativeEvent e) :on-submit-editing #(do (.clear @inp-ref)
key (.-key native-event) (.focus @inp-ref)
modifiers (js->clj (.-modifiers native-event)) (re-frame/dispatch [:chat.ui/send-current-message]))
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]))))
:on-change (fn [e] :on-change (fn [e]
(let [native-event (.-nativeEvent e) (let [native-event (.-nativeEvent e)
text (.-text native-event)] text (.-text native-event)]