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.text doesn't reflect it's value in the UI #153

Open
paulsonnentag opened this issue Jul 16, 2018 · 1 comment
Open

Input.text doesn't reflect it's value in the UI #153

paulsonnentag opened this issue Jul 16, 2018 · 1 comment

Comments

@paulsonnentag
Copy link

The big picture of what I'm trying to do

I want to be able to change the value of a text field by changing the value in the model. In my application the changes didn't get reflected in the displayed value of the input field.

What I did

I've created an minimal example where I set the value of the input field to a fixed value:

https://ellie-app.com/N7Np2wTJjBa1

What I Expected To Happen

The text in the input field shouldn't change when the user tries to enter text.

What Actually Happened

The text in the input field changes when the user enters text. This leads to a discrepancy between the defined view and the rendered ui.

I think that the problem is that the value get's set as an attribute and not a property

If I inspect the element with the devtools in chrome the correct value is set (123)

screen shot 2018-07-16 at 15 23 38

The property "value" has the wrong value

$0.value // = "123asdf"

The attribute "value" has the correct value

$0.getAttribute("value") // 123

Versions

  • Elm: 0.18
  • style-elements: 4.3.0
  • Browser: This problem occurs in multiple browsers
  • Operating System: macOS 10.13.5
@paulsonnentag
Copy link
Author

As a temporary workaround I've added the value as a property

Input.text None
                [ property "value" (Encode.string model.text) -- set value explicitly as property
                ]
                { onChange = ChangeInput
                , value = model.text
                , label =
                    Input.placeholder
                        { label = Input.labelLeft (el None [ ] (text "Search"))
                        , text = "placeholder"
                        }
                , options = []
                }       

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

No branches or pull requests

1 participant