Comments (12)
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.
from elm-form.
Using defaultValue
, if the user edit the textarea once, any further update from javascript is not reflected.
I still haven't found a solution for both issues.
from elm-form.
@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.
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.
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.
@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.
Sounds right! PR merged, thanks. Yes, an update on example and docs would be valuable :)
from elm-form.
@etaque Can I close this issue since it is fixed? Can you make sure a new packages is uploaded?
from elm-form.
thanks @pablohirafuji ! closing this, and a new package is coming.
from elm-form.
5.0.1 is out
from elm-form.
@etaque Thank you for this package!
from elm-form.
Related Issues (20)
- Nesting a multiple field validation loses the error HOT 2
- Initial textarea value on IE does not work HOT 3
- Example code typo in README
- Support for Ints? HOT 2
- validation it kick off onBlur for initially empty values HOT 1
- Providing default values to nested records?
- How to validate input1 value is the same as input2 value HOT 1
- Email validator too permissive? HOT 2
- Custom Error after validating through an API
- Why is "elm-test" a dependency? HOT 2
- Why no Form.Cancel message?
- Validation error doesn't appear under `liveError`
- Ability to persist form state as JSON ?
- Dependency on elm-test causes compatibility error HOT 1
- Exception Thrown in Output. ReferenceError: Elm is not defined
- Extend Form.Input to support date input
- Example does not compile (Elm 0.19.1)
- Update to `elm-explorations/[email protected]`
- Form Input maintained on Reset HOT 2
- Form validation for more than 8 fields? HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from elm-form.