Git Product home page Git Product logo

Comments (12)

pablohirafuji avatar pablohirafuji commented on May 26, 2024 2

Yes, you're absolutely right. I was thinking in someone new using the package. It's a frustrating experience not to be able to control the input visual value (happened to me :)).

Using defaultValue does not enforce anything like value does. So the user still can set the value attribute if changing the visual input value is desired, like:

Input.textArea state [ value model.state ]

I like this solution. Made a pull request with the change. Maybe add this to the docs help the new users.

from elm-form.

pablohirafuji avatar pablohirafuji commented on May 26, 2024 1

Done and done :)

from elm-form.

pablohirafuji avatar pablohirafuji commented on May 26, 2024

Using defaultValue, if the user edit the textarea once, any further update from javascript is not reflected.

More here and here.

I still haven't found a solution for both issues.

from elm-form.

etaque avatar etaque commented on May 26, 2024

@pablohirafuji when you say "update from javascript", do you include elm-generated js?
If it's just when trying to control an elm-originated textarea from js land, that's probably not the most common usage so it might be a sensible choice to use defaultValue.

from elm-form.

pablohirafuji avatar pablohirafuji commented on May 26, 2024

Consider this example (you can run it on http://elm-lang.org/try).

Using defaultValue, I can no longer reset the textarea visual value and it can be out of sync with the model value.

Using value, we have the "type really fast some update are overwritten" bug, but the visual value is always in sync with the model value.

So we have to choose which one is preferable. I think the value one has less critical downside.

If anyone know a solution that does not have neither downsides, please share.

from elm-form.

stil4m avatar stil4m commented on May 26, 2024

I see the problem you are stating with 'reset the textarea', but in many cases you will submit a form and the form will go away, you will not have to deal with resetting the form fields. In this case there is no 'problem' with using defaultValue, but can be with value. When I use Elm in production I would favour to use defaultValue instead of value in this case. In other cases, like resetting a form, I would favour value.

Would it be an possibility to use one of the two attributes by default in this package, but being able to pick the other if you explicitly state it? This gives may satisfy everybody their needs.

from elm-form.

pablohirafuji avatar pablohirafuji commented on May 26, 2024

@stil4m Thanks for pointing it!

@etaque Let me know if it makes sense. I can update the example (it makes use of Reset) and add this to the docs.

from elm-form.

etaque avatar etaque commented on May 26, 2024

Sounds right! PR merged, thanks. Yes, an update on example and docs would be valuable :)

from elm-form.

stil4m avatar stil4m commented on May 26, 2024

@etaque Can I close this issue since it is fixed? Can you make sure a new packages is uploaded?

from elm-form.

etaque avatar etaque commented on May 26, 2024

thanks @pablohirafuji ! closing this, and a new package is coming.

from elm-form.

etaque avatar etaque commented on May 26, 2024

5.0.1 is out

from elm-form.

pablohirafuji avatar pablohirafuji commented on May 26, 2024

@etaque Thank you for this package!

from elm-form.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.