backport of commit abd6324e50d6d785a4c51ea1a84c003b73aabdaf (#22465)

Co-authored-by: claire bontempo <68122737+hellobontempo@users.noreply.github.com>
This commit is contained in:
hc-github-team-secure-vault-core 2023-08-21 13:10:15 -04:00 committed by GitHub
parent d9a3586dea
commit 14cdb082bc
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 7 additions and 2 deletions

3
changelog/22458.txt Normal file
View File

@ -0,0 +1,3 @@
```release-note:bug
ui: fixes model defaults overwriting input value when user tries to clear form input
```

View File

@ -301,8 +301,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}}
{{on "change" this.onChangeWithEvent}}
{{on "input" this.onChangeWithEvent}}
{{on "keyup" this.handleKeyUp}}
class="input {{if this.validationError 'has-error-border'}}"
maxLength={{@attr.options.characterLimit}}

View File

@ -26,7 +26,8 @@ module('Integration | Component | form field', function (hooks) {
};
const setup = async function (attr) {
const model = EmberObject.create({});
// ember sets model attrs from the defaultValue key, mimicking that behavior here
const model = EmberObject.create({ [attr.name]: attr.options?.defaultValue });
const spy = sinon.spy();
this.set('onChange', spy);
this.set('model', model);