reagent-project / reagent-forms

Bootstrap form components for Reagent
339 stars 78 forks source link

Initial value on :list field not selected with Reagent 0.6.0 #113

Closed arttuka closed 7 years ago

arttuka commented 7 years ago

With Reagent 0.6.0, setting the initial value for a :list field no longer works. The first option is always initially selected, even if there is a value in the doc for the field.

To repeat the issue, add [reagent "0.6.0-rc"] to dependencies in the example project. Then the option list will initially display "foo" even though the initial value is set to "bar".

yogthos commented 7 years ago

Thanks for the report, I'll have to take a look at this when I get a chance.

arttuka commented 7 years ago

This bug seems to have disappeared with Reagent 0.6.0 final.

yogthos commented 7 years ago

glad to hear it. I'm meaning to do a bit of cleanup and I'll update to latest Reagent in the process. So, hopefully the next release should have some of the issues addressed.

hosiawak commented 7 years ago

I'm using Reagent 0.6.0 and the bug's still there.

yogthos commented 7 years ago

I'm unable to reproduce this with 0.6.0 actually, here's what I have:

(def template
  [:select.form-control {:field :list :id :many-options}
   [:option {:key :foo} "foo"]
   [:option {:key :bar} "bar"]
   [:option {:key :baz} "baz"]])

(defn home-page []
  (reagent/with-let [doc (atom {:many-options :bar})]
    [:div
     [bind-fields template doc]
     [:p (str @doc)]]))

The select is correctly initialized to :bar in my case.

@hosiawak Have you tried making sure that you've cleaned the project when updating the version?

hosiawak commented 7 years ago

@yogthos - I created a new project from scratch and it's fine now so I believe the issue can be closed. Wondering how I can clean the old project apart from running lein clean ?

hosiawak commented 7 years ago

I removed ~/.m2/repository/project-name and it has fixed it, many thanks.

yogthos commented 7 years ago

glad to hear it's working