Skip to content
Open
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
15 changes: 15 additions & 0 deletions packages/main/cypress/specs/ComboBox.cy.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,21 @@ describe("General Interaction", () => {
cy.get("[ui5-combobox]").should("have.prop", "focused", true);
});

it("shows focus outline on list item mousedown", () => {
cy.mount(
<ComboBox>
<ComboBoxItem text="One" />
<ComboBoxItem text="Two" />
</ComboBox>
);

cy.get("[ui5-combobox]").shadow().find(".inputIcon").realClick();
cy.get("[ui5-combobox]").shadow().find("[ui5-responsive-popover]").should("have.attr", "open");

cy.get("[ui5-cb-item]").first().shadow().find("li").realMouseDown();
cy.get("[ui5-cb-item]").first().should("have.prop", "focused", true);
});

it("tests Combo with two-column layout", () => {
cy.mount(
<ComboBox>
Expand Down
8 changes: 8 additions & 0 deletions packages/main/src/ComboBox.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1383,6 +1383,14 @@ class ComboBox extends UI5Element implements IFormInputElement {

_itemMousedown(e: MouseEvent) {
e.preventDefault();

const target = e.target as HTMLElement;
const listItem = target.closest<ComboBoxItem>("[ui5-cb-item], [ui5-cb-item-group]");

if (listItem) {
this._clearFocus();
listItem.focused = true;
}
}

_selectItem(e: CustomEvent<ListItemClickEventDetail>) {
Expand Down
Loading