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

fix(ui5-time-picker): firing change event after input change submit #4962

Merged
merged 1 commit into from
Mar 28, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions packages/main/src/TimePickerBase.js
Original file line number Diff line number Diff line change
Expand Up @@ -256,8 +256,10 @@ class TimePickerBase extends UI5Element {
value = this.normalizeValue(value); // transform valid values (in any format) to the correct format
}

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 ""
this.value = value;
if (!events.includes("input")) {
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 ""
this.value = value;
}
this.tempValue = value; // if the picker is open, sync it
this._updateValueState(); // Change the value state to Error/None, but only if needed
events.forEach(event => {
Expand Down
12 changes: 11 additions & 1 deletion packages/main/test/specs/TimePicker.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,8 @@ describe("TimePicker general interaction", () => {
it("tests change event", async () => {
const staticAreaItemClassName = await browser.getStaticAreaItemClassName("#timepickerChange");
const timepicker = await browser.$("#timepickerChange");
const icon = await timepicker.shadow$("ui5-input").$("ui5-icon");
const input = await timepicker.shadow$("ui5-input");
const icon = await input.$("ui5-icon");
const changeResult = await browser.$("#changeResult");

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

// assert
assert.strictEqual(await changeResult.getProperty("value"), "2", "Change fired as expected");

//act
await input.click();
await browser.keys("Backspace");
await browser.keys("7");
await browser.keys("Enter");

// assert
assert.strictEqual(await changeResult.getProperty("value"), "3", "Change fired as expected");
});

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