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
56 changes: 56 additions & 0 deletions packages/main/cypress/specs/Select.cy.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -1913,3 +1913,59 @@ describe("Select general interaction", () => {
.should("be.focused");
});
});

describe("Select - active/down state", () => {
it("applies active background on ui5-option while mouse is pressed", () => {
cy.mount(
<Select>
<Option>Option 1</Option>
<Option>Option 2</Option>
</Select>
);

cy.get("[ui5-select]").realClick();
cy.get("[ui5-select]").should("have.attr", "opened");

cy.get("[ui5-select]")
.find("[ui5-option]")
.eq(0)
.realMouseDown()
.then($option => {
const bg = window.getComputedStyle($option[0]).backgroundColor;
expect(bg).not.to.equal("rgba(0, 0, 0, 0)");
expect(bg).not.to.equal("transparent");
});

cy.get("[ui5-select]")
.find("[ui5-option]")
.eq(0)
.realMouseUp();
});

it("applies active background on ui5-option-custom while mouse is pressed", () => {
cy.mount(
<Select>
<OptionCustom>Option 1</OptionCustom>
<OptionCustom>Option 2</OptionCustom>
</Select>
);

cy.get("[ui5-select]").realClick();
cy.get("[ui5-select]").should("have.attr", "opened");

cy.get("[ui5-select]")
.find("[ui5-option-custom]")
.eq(0)
.realMouseDown()
.then($option => {
const bg = window.getComputedStyle($option[0]).backgroundColor;
expect(bg).not.to.equal("rgba(0, 0, 0, 0)");
expect(bg).not.to.equal("transparent");
});

cy.get("[ui5-select]")
.find("[ui5-option-custom]")
.eq(0)
.realMouseUp();
});
});
6 changes: 3 additions & 3 deletions packages/main/src/ListItemBaseTemplate.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import type ListItemBase from "./ListItemBase.js";
import type { AriaRole } from "@ui5/webcomponents-base/";
import type { AriaRole, JsxTemplate } from "@ui5/webcomponents-base/";

export default function ListItemBaseTemplate(this: ListItemBase, hooks?: { listItemContent: () => void }, injectedProps?: {
export default function ListItemBaseTemplate(this: ListItemBase, hooks?: { listItemContent: JsxTemplate }, injectedProps?: {
role?: AriaRole,
title?: string,
}) {
Expand All @@ -21,7 +21,7 @@ export default function ListItemBaseTemplate(this: ListItemBase, hooks?: { listI
onKeyDown={this._onkeydown}
onClick={this._onclick}
>
{ listItemContent.call(this) }
{ listItemContent.call(this) as JSX.Element }
</li>
);
}
Expand Down
7 changes: 4 additions & 3 deletions packages/main/src/themes/ListItemBase.css
Original file line number Diff line number Diff line change
Expand Up @@ -34,23 +34,24 @@
}

/* hovered */
:host([actionable]:not([active]):not([selected]):not([ui5-li-group-header]):hover) {
:host([actionable]:not([active]):not(:active):not([selected]):not([ui5-li-group-header]):hover) {
background-color: var(--sapList_Hover_Background);
}

:host([actionable]:not([active]):not([selected]):not([ui5-li-group-header]):hover) .ui5-li-additional-text {
:host([actionable]:not([active]):not(:active):not([selected]):not([ui5-li-group-header]):hover) .ui5-li-additional-text {
text-shadow: var(--sapContent_TextShadow);
}

/* selected and hovered */
:host([actionable][selected]:not([active], [data-moving]):hover) {
:host([actionable][selected]:not([active]):not(:active):not([data-moving]):hover) {
background-color: var(--sapList_Hover_SelectionBackground);
}

/* selected and active */
:host([active][actionable]:not([data-moving])),
:host([active][actionable][selected]:not([data-moving])) {
background-color: var(--sapList_Active_Background);
border-bottom-color: var(--sapList_Active_Background);
}

/* focused */
Expand Down
6 changes: 6 additions & 0 deletions packages/main/src/themes/OptionBase.css
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
:host {
height: var(--_ui5_list_item_dropdown_base_height);
--_ui5_list_item_title_size: var(--sapFontSize);
}

:host(:active[actionable]:not([data-moving])),
:host(:active[actionable][selected]:not([data-moving])) {
background-color: var(--sapList_Active_Background);
border-bottom-color: var(--sapList_Active_Background);
}
Loading