Skip to content
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 bug attribute value #239

Open
Norlock opened this issue Feb 11, 2025 · 2 comments · May be fixed by #241
Open

Input bug attribute value #239

Norlock opened this issue Feb 11, 2025 · 2 comments · May be fixed by #241

Comments

@Norlock
Copy link

Norlock commented Feb 11, 2025

Bug

I already had some weird issues before with the attribute value on anything else then text and integers, but I think I found the culprit.

The generic approach for getting any attribute through the getAttribute() function doesn't work with value. That's why decimal inputs don't update when you bind the value with attribute.value(...).

https://stackoverflow.com/questions/11973678/difference-between-element-value-and-element-getattributevalue

Maybe for attribute.value we can write a hack that will check for attribute name value and use element.value instead of the getAttribute(..).

Steps to reproduce

Write something like this:

      html.input([
        attribute.type_("number"),
        attribute.step(".01"),
        attribute.placeholder("Decimal"),
        attribute.value(value_str),
        event.on_input(SetInput),
      ])

You can just bind it to some string. Then try to type 121.23. you will see that the dot will never be inserted. If you use any special character like ",", ";" it will completely remove the input. When you comment out the attribute.value input it will undo the wrong binding.

@hayleigh-dot-dev
Copy link
Collaborator

Maybe for attribute.value we can write a hack that will check for attribute name value and use element.value instead of the getAttribute(..).

Yeah sounds super reasonable, we have to special-case a bunch of stuff like this. This one must have fallen through the cracks!

@Norlock
Copy link
Author

Norlock commented Feb 11, 2025

Ok nice!

@Norlock Norlock linked a pull request Feb 11, 2025 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants