Skip to content

Commit 2e3f428

Browse files
fix(ui5-time-picker): firing change event after input change submit (#4962)
fixes: #4918
1 parent 6a096cb commit 2e3f428

File tree

2 files changed

+15
-3
lines changed

2 files changed

+15
-3
lines changed

packages/main/src/TimePickerBase.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -256,8 +256,10 @@ class TimePickerBase extends UI5Element {
256256
value = this.normalizeValue(value); // transform valid values (in any format) to the correct format
257257
}
258258

259-
this.value = ""; // Do not remove! DurationPicker use case -> value is 05:10, user tries 05:12, after normalization value is changed back to 05:10 so no invalidation happens, but the input still shows 05:12. Thus we enforce invalidation with the ""
260-
this.value = value;
259+
if (!events.includes("input")) {
260+
this.value = ""; // Do not remove! DurationPicker use case -> value is 05:10, user tries 05:12, after normalization value is changed back to 05:10 so no invalidation happens, but the input still shows 05:12. Thus we enforce invalidation with the ""
261+
this.value = value;
262+
}
261263
this.tempValue = value; // if the picker is open, sync it
262264
this._updateValueState(); // Change the value state to Error/None, but only if needed
263265
events.forEach(event => {

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

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,8 @@ describe("TimePicker general interaction", () => {
9090
it("tests change event", async () => {
9191
const staticAreaItemClassName = await browser.getStaticAreaItemClassName("#timepickerChange");
9292
const timepicker = await browser.$("#timepickerChange");
93-
const icon = await timepicker.shadow$("ui5-input").$("ui5-icon");
93+
const input = await timepicker.shadow$("ui5-input");
94+
const icon = await input.$("ui5-icon");
9495
const changeResult = await browser.$("#changeResult");
9596

9697
// act - submit the same time
@@ -128,6 +129,15 @@ describe("TimePicker general interaction", () => {
128129

129130
// assert
130131
assert.strictEqual(await changeResult.getProperty("value"), "2", "Change fired as expected");
132+
133+
//act
134+
await input.click();
135+
await browser.keys("Backspace");
136+
await browser.keys("7");
137+
await browser.keys("Enter");
138+
139+
// assert
140+
assert.strictEqual(await changeResult.getProperty("value"), "3", "Change fired as expected");
131141
});
132142

133143
it("tests value state", async () => {

0 commit comments

Comments
 (0)