[#6042] [desktop] fix Caret position is changed when typing fast in input message field
This commit is contained in:
parent
c91e503b94
commit
b6bb596a00
|
@ -189,6 +189,17 @@
|
||||||
:current-public-key current-public-key)]))]]
|
:current-public-key current-public-key)]))]]
|
||||||
[connectivity/error-view]])))
|
[connectivity/error-view]])))
|
||||||
|
|
||||||
|
(views/defview send-button [inp-ref]
|
||||||
|
(views/letsubs [{:keys [input-text]} [:get-current-chat]]
|
||||||
|
(let [empty? (= "" input-text)]
|
||||||
|
[react/touchable-highlight {:style styles/send-button
|
||||||
|
:on-press (fn []
|
||||||
|
(.clear @inp-ref)
|
||||||
|
(.focus @inp-ref)
|
||||||
|
(re-frame/dispatch [:chat.ui/send-current-message]))}
|
||||||
|
[react/view {:style (styles/send-icon empty?)}
|
||||||
|
[icons/icon :icons/arrow-left {:style (styles/send-icon-arrow empty?)}]]])))
|
||||||
|
|
||||||
(views/defview chat-text-input [chat-id input-text]
|
(views/defview chat-text-input [chat-id input-text]
|
||||||
(views/letsubs [inp-ref (atom nil)]
|
(views/letsubs [inp-ref (atom nil)]
|
||||||
{:should-component-update
|
{:should-component-update
|
||||||
|
@ -197,7 +208,7 @@
|
||||||
(not= old-chat-id new-chat-id))}
|
(not= old-chat-id new-chat-id))}
|
||||||
(let [component (reagent/current-component)
|
(let [component (reagent/current-component)
|
||||||
set-container-height-fn #(reagent/set-state component {:container-height %})
|
set-container-height-fn #(reagent/set-state component {:container-height %})
|
||||||
{:keys [container-height empty?] :or {empty? true}} (reagent/state component)]
|
{:keys [container-height]} (reagent/state component)]
|
||||||
[react/view {:style (styles/chat-box container-height)}
|
[react/view {:style (styles/chat-box container-height)}
|
||||||
[react/text-input {:placeholder (i18n/label :t/type-a-message)
|
[react/text-input {:placeholder (i18n/label :t/type-a-message)
|
||||||
:auto-focus true
|
:auto-focus true
|
||||||
|
@ -220,15 +231,8 @@
|
||||||
: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)]
|
||||||
(reagent/set-state component {:empty? (= "" text)})
|
|
||||||
(re-frame/dispatch [:chat.ui/set-chat-input-text text])))}]
|
(re-frame/dispatch [:chat.ui/set-chat-input-text text])))}]
|
||||||
[react/touchable-highlight {:style styles/send-button
|
[send-button inp-ref]])))
|
||||||
:on-press (fn []
|
|
||||||
(.clear @inp-ref)
|
|
||||||
(.focus @inp-ref)
|
|
||||||
(re-frame/dispatch [:chat.ui/send-current-message]))}
|
|
||||||
[react/view {:style (styles/send-icon empty?)}
|
|
||||||
[icons/icon :icons/arrow-left {:style (styles/send-icon-arrow empty?)}]]]])))
|
|
||||||
|
|
||||||
(views/defview chat-view []
|
(views/defview chat-view []
|
||||||
(views/letsubs [{:keys [input-text chat-id] :as current-chat} [:get-current-chat]]
|
(views/letsubs [{:keys [input-text chat-id] :as current-chat} [:get-current-chat]]
|
||||||
|
|
Loading…
Reference in New Issue