FIX: Inputs using focusout regressed in #17345 (#17389)

This commit is contained in:
Jarek Radosz
2022-07-08 13:00:33 +02:00
committed by GitHub
parent a084680f1d
commit 20851f7240
9 changed files with 104 additions and 14 deletions
@@ -22,17 +22,23 @@ export default Component.extend({
},
actions: {
changeKey(index, newValue) {
changeKey(index, event) {
const newValue = event.target.value;
if (this._checkInvalidInput(newValue)) {
return;
}
this._replaceValue(index, newValue, "key");
},
changeSecret(index, newValue) {
changeSecret(index, event) {
const newValue = event.target.value;
if (this._checkInvalidInput(newValue)) {
return;
}
this._replaceValue(index, newValue, "secret");
},
@@ -24,8 +24,8 @@ export default Component.extend({
},
@action
changeValue(index, newValue) {
this.collection.replace(index, 1, [newValue]);
changeValue(index, event) {
this.collection.replace(index, 1, [event.target.value]);
this.collection.arrayContentDidChange(index);
this._onChange();
},
@@ -65,7 +65,7 @@ export default Component.extend({
},
_onChange() {
this.attrs.onChange && this.attrs.onChange(this.collection);
this.onChange?.(this.collection);
},
@discourseComputed("collection")
@@ -39,8 +39,8 @@ export default Component.extend({
},
actions: {
changeValue(index, newValue) {
this._replaceValue(index, newValue);
changeValue(index, event) {
this._replaceValue(index, event.target.value);
},
addValue(newValue) {
@@ -3,8 +3,8 @@
{{#each this.collection as |value index|}}
<div class="value" data-index={{index}}>
<DButton @action={{action "removeValue"}} @actionParam={{value}} @icon="times" @class="remove-value-btn btn-small" />
<Input @value={{value.key}} class="value-input" {{on "focusout" (action "changeKey" index)}} />
<Input @value={{value.secret}} class="value-input" @type={{if this.isSecret "password" "text"}} {{on "focusout" (action "changeSecret" index)}} />
<Input @value={{value.key}} class="value-input" {{on "focusout" (fn (action "changeKey") index)}} />
<Input @value={{value.secret}} class="value-input" @type={{if this.isSecret "password" "text"}} {{on "focusout" (fn (action "changeSecret") index)}} />
</div>
{{/each}}
</div>
@@ -4,7 +4,7 @@
<div data-index={{index}} class="value">
<DButton @action={{action "removeValue"}} @actionParam={{value}} @icon="times" @class="remove-value-btn btn-small" />
<Input title={{value}} @value={{value}} class="value-input" {{on "focusout" (action "changeValue" index)}} />
<Input title={{value}} @value={{value}} class="value-input" {{on "focusout" (fn (action "changeValue") index)}} />
{{#if this.showUpDownButtons}}
<DButton @action={{action "shift" -1 index}} @icon="arrow-up" @class="shift-up-value-btn btn-small" />
@@ -4,7 +4,7 @@
<div data-index={{index}} class="value">
<DButton @action={{action "removeValue"}} @actionParam={{value}} @icon="times" @class="remove-value-btn btn-small" />
<Input title={{value}} @value={{value}} class="value-input" {{on "focusout" (action "changeValue" index)}} />
<Input title={{value}} @value={{value}} class="value-input" {{on "focusout" (fn (action "changeValue") index)}} />
{{#if this.showUpDownButtons}}
<DButton @action={{action "shift" -1 index}} @icon="arrow-up" @class="shift-up-value-btn btn-small" />