Skip to content

Commit a5f27f2

Browse files
fix(ui5-step-input): firing step input once when value is deleted (#3474)
fixes: #3457
1 parent 2f67084 commit a5f27f2

File tree

2 files changed

+26
-2
lines changed

2 files changed

+26
-2
lines changed

packages/main/src/StepInput.js

+7-2
Original file line numberDiff line numberDiff line change
@@ -502,8 +502,10 @@ class StepInput extends UI5Element {
502502
}
503503

504504
_fireChangeEvent() {
505-
this._previousValue = this.value;
506-
this.fireEvent("change", { value: this.value });
505+
if (this._previousValue !== this.value) {
506+
this._previousValue = this.value;
507+
this.fireEvent("change", { value: this.value });
508+
}
507509
}
508510

509511
/**
@@ -553,6 +555,9 @@ class StepInput extends UI5Element {
553555
}
554556

555557
_onInputChange(event) {
558+
if (this.input.value === "") {
559+
this.input.value = this.min || 0;
560+
}
556561
const inputValue = this._preciseValue(parseFloat(this.input.value));
557562
if (this.value !== this._previousValue || this.value !== inputValue) {
558563
this.value = inputValue;

packages/main/test/specs/StepInput.spec.js

+19
Original file line numberDiff line numberDiff line change
@@ -424,6 +424,25 @@ describe("'change' event firing", () => {
424424
assert.strictEqual(Number(changeResult.getProperty("value")), 2, "'change' event is fired 2 times");
425425
});
426426

427+
it("'change' event should be fired once after element deleted and focus out", () => {
428+
browser.url(`http://localhost:${PORT}/test-resources/pages/StepInput.html`);
429+
const siCozy = $("#stepInputCozy");
430+
const siMinMax = $("#stepInputMinMax");
431+
const changeResult = $("#changeResult");
432+
433+
siMinMax.click();
434+
siMinMax.keys("ArrowUp");
435+
siMinMax.keys("ArrowUp");
436+
siMinMax.keys("ArrowUp");
437+
siCozy.click();
438+
assert.strictEqual(siMinMax.getProperty("value"), 3, "Value is increased correctly to 3");
439+
assert.strictEqual(Number(changeResult.getProperty("value")), 1, "'change' event is fired 1 time");
440+
siMinMax.doubleClick();
441+
siMinMax.keys("Backspace");
442+
siCozy.click();
443+
assert.strictEqual(siMinMax.getProperty("value"), 0, "Value is increased correctly to 1");
444+
assert.strictEqual(Number(changeResult.getProperty("value")), 2, "'change' event is fired 2 times");
445+
});
427446
});
428447

429448
describe("Accessibility related parameters", () => {

0 commit comments

Comments
 (0)