antizer
antizer copied to clipboard
Text cursor jumps to last position for ant/input controllable value
It works fine with html [:input], but for ant/input check this:
(defn example [_]
(let [state (r/atom {:title ""})]
(fn [_]
[ant/form
[ant/form-item
[ant/input
{:value (:title @state)
:on-change (fn [e] (swap! state assoc :title (.. e -target -value)))
:placeholder "Title"}]]])))
Hello. According to Antd docs you can use defaultValue
attribute not value
. Maybe Input
component handle changing state automatically (I don't see value
attribute in docs).
Did you look here? https://ant.design/components/input/
defaultValue | The initial input content | string | ... value | The input content value | string ...
When Input is used in a Form.Item context, if the Form.Item has the id and options props defined then value, defaultValue, and id props of Input are automatically set.
-- So example looks correct for me.