-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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
UI: fix default values resetting form inputs #22458
UI: fix default values resetting form inputs #22458
Conversation
…r changes by updating the input value with a model's default
{{on "change" this.onChangeWithEvent}} | ||
{{on "input" this.onChangeWithEvent}} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
required for model validations that happen when the input changes (not just on submit)
Part of the bug fix for #8656 |
Build Results: |
@@ -306,8 +306,9 @@ | |||
disabled={{and @attr.options.editDisabled (not @model.isNew)}} | |||
autocomplete="off" | |||
spellcheck="false" | |||
value={{or (get @model this.valuePath) @attr.options.defaultValue}} | |||
value={{get @model this.valuePath}} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ember sets the @model
attribute with whatever the defaultValue
is - so this extra logic was redundant and causing overwrites docs
CI Results: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for tackling!
This reverts the work in this PR #22243 and actually solves the issue where the model default was overwriting the input and disallowing a user to clear the input
This line is redundant because
get @model this.valuePath
grabs the model default if there was one, so this was setting it again. Ember sets a model's attribute using thedefaultValue
and wherever we useFormField
we also pass in the@model
🐛 in the gif I'm clicking
backspace
but as soon as the input is cleared the value is replaced by thedefaultValue
- which is frustrating UX. For consistency the input should reflect the user's changes (which exist on the model)