-
-
Notifications
You must be signed in to change notification settings - Fork 66
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Input loses focus when initial value is nil
#140
Comments
@roman01la Your input element changes from being a "uncontrolled" input (the value nil, which sablono maps to js/undefined) to being a "controlled" input ( a value different than nil). I think this is not supported by React. You should use either a controlled, or an uncontrolled input, but not switch. Switching between them means for React you are using 2 different components. That's why you loose focus. You could use either the blank string in your atom or call I don't know of a better solution at the moment. |
@r0man That's interesting, because ClojureScript compiler actually translates
I agree that it's probably better to follow React requirements. But why does input lose focus? Does sablono render different components when switching between uncontrolled and controlled? |
@roman01la The idea was since nil isn't allowed anyways (you get a warning), use nil for uncontrolled inputs and anything else for controlled inputs. Not sure if that was a good idea. Regarding the focus, this is because React treats the change from uncontrolled to controlled as 2 different components. At least that is my understanding. |
@r0man Interesting.. I just checked, in JavaScript the change from uncontrolled to controlled doesn't make input to loose focus http://jsbin.com/lurajaheko/edit?js,console,output |
@roman01la Hmm, interesting. I guess then we have an issue with this beast again :( |
@r0man I had some time to dig into interpreter and I found the issue. It is actually renders two different components, because of Should |
Fixed in master |
I noticed that an input field loses focus on very first character typed in, when the initial value is
nil
. It works fine with an empty string.Here's a minimal reproducible example:
The text was updated successfully, but these errors were encountered: