chat: fix #1390, selection OOB

When the input field includes an unmatched " in the input-text, there's a
mismatch between the parsed command-args and the length of the text field,
causing text selection to be out of bounds. By bounding the new selection to a
maximum of the input text, this is avoided.
This commit is contained in:
Oskar Thorén 2017-07-28 10:53:57 +02:00 committed by Roman Volosovskyi
parent d90dab8711
commit 7eb5cdb9ab
1 changed files with 3 additions and 2 deletions

View File

@ -388,7 +388,8 @@
new-sel (->> command-args
(take (+ 3 arg-pos))
(input-model/join-command-args)
(count))
count
(min (count input-text)))
ref (get-in chat-ui-props [current-chat-id :input-ref])]
(.setNativeProps ref (clj->js {:selection {:start new-sel :end new-sel}}))
(dispatch [:update-text-selection new-sel]))))))