Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Text cursor jumps to last position for ant/input controllable value #28

Open
amakurin opened this issue Mar 4, 2019 · 2 comments
Open

Comments

@amakurin
Copy link

amakurin commented Mar 4, 2019

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"}]]])))
@mishazawa
Copy link

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).

@amakurin
Copy link
Author

amakurin commented Mar 13, 2019

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants