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

UI: fix default values resetting form inputs #22458

Merged
merged 5 commits into from
Aug 20, 2023

Conversation

hellobontempo
Copy link
Contributor

@hellobontempo hellobontempo commented Aug 18, 2023

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 the defaultValue and wherever we use FormField 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 the defaultValue - which is frustrating UX. For consistency the input should reflect the user's changes (which exist on the model)

model-overwrite

@hellobontempo hellobontempo added this to the 1.13.6 milestone Aug 18, 2023
@github-actions github-actions bot added the hashicorp-contributed-pr If the PR is HashiCorp (i.e. not-community) contributed label Aug 18, 2023
{{on "change" this.onChangeWithEvent}}
{{on "input" this.onChangeWithEvent}}
Copy link
Contributor Author

@hellobontempo hellobontempo Aug 18, 2023

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)

@hellobontempo hellobontempo changed the title UI/actually fix default resetting value main UI: fix default values resetting inputs Aug 18, 2023
@hellobontempo hellobontempo added the bug Used to indicate a potential bug label Aug 18, 2023
@hellobontempo
Copy link
Contributor Author

Part of the bug fix for #8656

@hellobontempo hellobontempo changed the title UI: fix default values resetting inputs UI: fix default values resetting form inputs Aug 18, 2023
@github-actions
Copy link

Build Results:
All builds succeeded! ✅

@@ -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}}
Copy link
Contributor Author

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

@github-actions
Copy link

CI Results:
All Go tests succeeded! ✅

Copy link
Contributor

@Monkeychip Monkeychip left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for tackling!

@hellobontempo hellobontempo merged commit abd6324 into main Aug 20, 2023
103 checks passed
@hellobontempo hellobontempo deleted the ui/actually-fix-default-resetting-value-main branch August 20, 2023 17:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Used to indicate a potential bug hashicorp-contributed-pr If the PR is HashiCorp (i.e. not-community) contributed ui
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants