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:
parent
d90dab8711
commit
7eb5cdb9ab
|
@ -388,7 +388,8 @@
|
||||||
new-sel (->> command-args
|
new-sel (->> command-args
|
||||||
(take (+ 3 arg-pos))
|
(take (+ 3 arg-pos))
|
||||||
(input-model/join-command-args)
|
(input-model/join-command-args)
|
||||||
(count))
|
count
|
||||||
|
(min (count input-text)))
|
||||||
ref (get-in chat-ui-props [current-chat-id :input-ref])]
|
ref (get-in chat-ui-props [current-chat-id :input-ref])]
|
||||||
(.setNativeProps ref (clj->js {:selection {:start new-sel :end new-sel}}))
|
(.setNativeProps ref (clj->js {:selection {:start new-sel :end new-sel}}))
|
||||||
(dispatch [:update-text-selection new-sel]))))))
|
(dispatch [:update-text-selection new-sel]))))))
|
Loading…
Reference in New Issue