mdgriffith / elm-ui

What if you never had to write CSS again?
https://package.elm-lang.org/packages/mdgriffith/elm-ui/latest/
BSD 3-Clause "New" or "Revised" License
1.35k stars 110 forks source link

Cannot change text input contents #271

Closed hololeap closed 3 years ago

hololeap commented 3 years ago

I cannot change the contents of a text input box after it has been rendered.

Example: https://ellie-app.com/cjJVPmM7zBBa1

It has the same problem if you change the text field:

                { onChange = Change
                , text = ""
                , placeholder = Nothing
                , label = labelAbove [] (Element.text "Text to reverse")
                }

This is frustrating because I was excited to try this library, but this basic functionality seems totally broken.

Versions elm-0.19.1 elm-ui-1.1.8

Tested in:

bburdette commented 3 years ago

Here, try this:

https://ellie-app.com/cjKXPxrZ2Pwa1

Stick with it, elm-ui is awesome : )

hololeap commented 3 years ago

@bburdette Wow, thanks! I didn't expect the fix to be so simple. That's going to save me a huge headache.

Maybe there should be something in the docs on this? I was totally clueless what the text field was for. I figured it was some sort of initial value.

bburdette commented 3 years ago

The way it works is typical for elm UI things in general (html, elm-ui, or other) - your "view" fn takes your model data and builds the UI with it, seemingly from scratch every time. Initial values are not kept in UI elements, but in the model data.

For more rapid response on these kinds of issues, I recommend the elm slack: https://elmlang.herokuapp.com/

There are a lot of channels on there, #beginners is a great place to check out, as well as #elm-ui.

hololeap commented 3 years ago

@bburdette Thanks again. I was asking on #elm IRC in Freenode and wasn't getting any responses.