Skip to content
New issue

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

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

Already on GitHub? # to your account

<input> defaults to being a controlled component #12

Closed
TanYewWei opened this issue Feb 3, 2014 · 4 comments
Closed

<input> defaults to being a controlled component #12

TanYewWei opened this issue Feb 3, 2014 · 4 comments

Comments

@TanYewWei
Copy link

I noticed this issue when I was working on my toy project.

Specifically, upgrading to the latest version of sablono (version 0.2.5) made it impossible to enter text into the "What needs to be done" input shown in the image below:

I'm running on the latest Mac OSX (10.9.1), with the project dependencies specified in this file -- https://github.com/TanYewWei/pedestal-om-todo/blob/master/project.clj


Everything works with sablono 0.2.3 and below.

It seems like inputs are given a value attribute by default, and React then treats that input as a controlled component.

The problem for my app above was that adding a defaultValue attribute did not change my input into an uncontrolled component (as I wanted).

I think this behaviour was introduced in the following commit -- 8bcbef9

Maybe a possible fix would be to introduce an arity-4 version of sablono.core/input-field function, which allows specifying a defaultValue, and then using that defaultValue in place of value if present?

Any ideas on what could be the problem, and how best to go about fixing it?

Thanks.

@paulfedorow
Copy link

The bug is in the wrap-form-element function. This function is copied from om.
swannodette has fixed the problem in om 0.3.4: omcljs/om@897baeb

@TanYewWei
Copy link
Author

I'm pretty sure that's not the case with my code, since I can reproduce the same error by using Om 0.3.5, and then changing between sablono versions (0.2.3 works, but 0.2.4 and 0.2.5 don't).

@paulfedorow
Copy link

sablono doesn't use om's wrap-form-element function, so the om version is irrelevant. I guess r0man has copied the function instead of relying on om's implementation to circumvent pulling in om as a dependency (#10 (comment)).

Thus it has to be fixed in both om (already fixed) and in sablono.

@r0man r0man closed this as completed in e0c47d4 Feb 4, 2014
@r0man
Copy link
Owner

r0man commented Feb 4, 2014

Fixed in 0.2.6.

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

No branches or pull requests

3 participants