-
Notifications
You must be signed in to change notification settings - Fork 91
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
Setting value
of an input
doesn't seem to work
#61
Comments
I just ran into this one, where |
Depends on how you set it. |
This is turning out to be my primary issue with karax which is otherwise excellent. The The following is something that's been biting me for a while (on top of Here's a list of It's more obvious with a list of Notice how no matter which element I remove, it's the last one in the list that seems to be affected (in terms of the input value, the color etc seems ok). I don't think |
@citycide Please try to give the elements an |
This doesn't work for server-side rendering either. import karax/[karaxdsl, vdom]
echo buildHtml(input(`type`="text", value="test"))
echo buildHtml(input(`type`="text", value="test", id="test", placeholder="test")) Output: <input type="text"></input>
<input id="test" type="text" placeholder="test"></input> |
import karax / [vdom, karaxdsl, karax, jstrutils]
var value = 1
proc createDom(): VNode =
buildHtml(tdiv):
kout value
input(id=id, placeholder = $v, value = $v)
button(onclick = proc(e:Event, n:VNode) =
value.inc
): text "change"
setRenderer createDom value should work like how placeholder works . For those who wants to use input value as expected, including SSR, I found a workaround in karaxdsl.nim as following
|
bump, this still has no solution |
Change proposed in karaxnim#61 (comment)
Looks like commit f6bda9a didn't fix it. I can reproduce the bug with this snippet (cleaned up @gogolxdong's to compile correctly): import karax / [vdom, karaxdsl, karax, jstrutils]
var v = 1
proc createDom(): VNode =
buildHtml(tdiv):
kout v
input(id="myid", placeholder = $v, value = $v)
button(onclick = proc(e:Event, n:VNode) =
v.inc
): text "change"
setRenderer createDom Using karax 1.1.2 & nim devel. |
I can also reproduce on Karax 1.2.1. Not super sure what the best option is here, as it seems that Karax doesn't think that the value has changed so the input isn't redrawn correctly? Like if I do this import karax / [kdom, vdom, karaxdsl, karax, jstrutils]
var v = 1
proc createDom(): VNode =
buildHtml(tdiv):
kout v
input(id= $v, placeholder = $v, value = $v)
button(onclick = proc(e:Event, n:VNode) =
v.inc
): text "change"
setRenderer createDom everything works fine, because the id changes so Karax knows to update the dom. |
@ajusa this is actually an issue with HTML itself. For an input tag, |
No description provided.
The text was updated successfully, but these errors were encountered: