Skip to content

Commit

Permalink
fix chang event after selection and add tests case
Browse files Browse the repository at this point in the history
  • Loading branch information
MapTo0 committed Jun 21, 2021
1 parent b0f8f04 commit d218915
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 0 deletions.
11 changes: 11 additions & 0 deletions packages/main/src/ComboBox.js
Original file line number Diff line number Diff line change
Expand Up @@ -443,6 +443,11 @@ class ComboBox extends UI5Element {
if (isPhone()) {
this.blur();
}

if (this._selectionPerformed) {
this._lastValue = this.value;
this._selectionPerformed = false;
}
}

_toggleRespPopover() {
Expand Down Expand Up @@ -684,6 +689,12 @@ class ComboBox extends UI5Element {
const listItem = event.detail.item;

this._selectedItemText = listItem.mappedItem.text;
this._selectionPerformed = true;

if (this.value === this._selectedItemText) {
return this._closeRespPopover();
}

this.value = this._selectedItemText;

if (!listItem.mappedItem.selected) {
Expand Down
25 changes: 25 additions & 0 deletions packages/main/test/specs/ComboBox.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,31 @@ describe("General interaction", () => {

assert.strictEqual(placeholder.getText(), "Argentina", "Text should be empty");
assert.strictEqual(counter.getText(), "1", "Call count should be 1");

arrow.click();

assert.strictEqual(counter.getText(), "1", "Call count should be 1");

arrow.click();

popover.$("ui5-list").$$("ui5-li")[1].click();
assert.strictEqual(counter.getText(), "2", "Call count should be 2");
});

it ("Tests change event after selection", () => {
browser.url(`http://localhost:${PORT}/test-resources/pages/ComboBox.html`);

const counter = $("#change-count");
const combo = $("#change-cb");
const placeholder = $("#change-placeholder");
const arrow = combo.shadow$("[input-icon]");

arrow.click();

// click on first item
const staticAreaItemClassName = browser.getStaticAreaItemClassName("#change-cb");
const popover = browser.$(`.${staticAreaItemClassName}`).shadow$("ui5-responsive-popover");
popover.$("ui5-list").$$("ui5-li")[0].click();
});

it ("Tests input event", () => {
Expand Down

0 comments on commit d218915

Please sign in to comment.