Skip to content

It's impossible to set value= on <input> elements? #4293

Open
@TheLostLambda

Description

@TheLostLambda

Problem

I'm talking about this value: https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/input#value.

It's used as a default value that, for example, form resets return to. After calling reset (https://developer.mozilla.org/en-US/docs/Web/API/HTMLFormElement/reset), I expected my values to return to those I specified in rsx! like this:

input {
    value: "5",
    min: "0",
    r#type: "number",
    required: "true",
}

But instead of returning the input to the value 5, it clears it!

Looking at the HTML, this seems to be because value is treated specially in RSX, so it's not actually even setting the value=... on the ` element!

Steps To Reproduce

Steps to reproduce the behavior:

  • Create an input in RSX and specify value: "foo"
  • Examine the generated HTML and see that the value="foo" is absent!

Expected behavior

Should have <input value="foo" ... />

Environment:

  • Dioxus version: 0.6.3

I think it would be fine to just add the value=... when the <input> element is created?

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions