Skip to content

Commit

Permalink
fix(ui5-combobox): close popover on "Enter" key press
Browse files Browse the repository at this point in the history
Now, popover is closed when "Enter" key is pressed.

Fixes: #1940
  • Loading branch information
nnaydenow committed Jul 14, 2020
1 parent 23fb8b7 commit f0e2bac
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 1 deletion.
3 changes: 2 additions & 1 deletion packages/main/src/ComboBox.js
Original file line number Diff line number Diff line change
Expand Up @@ -489,6 +489,8 @@ class ComboBox extends UI5Element {
this.fireEvent("change");
this.inner.setSelectionRange(this.value.length, this.value.length);
}

this._closeRespPopover();
}

_selectItem(event) {
Expand All @@ -504,7 +506,6 @@ class ComboBox extends UI5Element {
});

this._inputChange();
this._closeRespPopover();
}

get _headerTitleText() {
Expand Down
31 changes: 31 additions & 0 deletions packages/main/test/specs/ComboBox.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,37 @@ describe("General interaction", () => {
assert.notOk(popover.getProperty("opened"), "Popover should close");
});

it ("Should close popover on item click / change event", () => {
browser.url("http://localhost:8080/test-resources/pages/ComboBox.html");

const combo = $("#combo2");
const arrow = combo.shadow$("[input-icon]");
const input = combo.shadow$("#ui5-combobox-input");
const staticAreaItemClassName = browser.getStaticAreaItemClassName("#combo2");
const popover = browser.$(`.${staticAreaItemClassName}`).shadow$("ui5-responsive-popover");
let listItems = popover.$("ui5-list").$$("ui5-li");

// act
input.click();
input.keys("b");

// assert
assert.ok(popover.getProperty("opened"), "Popover should be opened");

// act
input.keys("Enter");

// assert
assert.notOk(popover.getProperty("opened"), "Popover should be closed");

// act
arrow.click();
listItems[0].click();

// assert
assert.notOk(popover.getProperty("opened"), "Popover should be closed");
});

it ("Tests change event", () => {
const dummyTarget = $("#combo");
const placeholder = $("#change-placeholder");
Expand Down

0 comments on commit f0e2bac

Please sign in to comment.