diff --git a/packages/calcite-components/src/components/combobox-item/combobox-item.scss b/packages/calcite-components/src/components/combobox-item/combobox-item.scss index b5d6d081e22..b523d6461ca 100644 --- a/packages/calcite-components/src/components/combobox-item/combobox-item.scss +++ b/packages/calcite-components/src/components/combobox-item/combobox-item.scss @@ -71,25 +71,22 @@ ul:focus { @apply cursor-default; } -// selected state -.label--selected { - @apply text-color-1; - - .title { - @apply font-medium; - } -} - .label--active { @apply focus-inset; } -.label:hover, +:host([selected]) .label, .label:active { - @apply text-color-1 - bg-foreground-2 - no-underline - shadow-none; + @apply text-color-1; + + .description, + .short-text { + @apply text-color-2; + } +} + +.label:hover { + @apply text-color-1 bg-foreground-2; } .label:active { @@ -101,22 +98,17 @@ ul:focus { opacity-0 duration-150 ease-in-out; - color: theme("borderColor.color.1"); -} - -.icon--custom { - margin-block-start: -1px; -} - -.icon--selected { - @apply text-color-1; } -.label--selected .icon { +:host([selected]) .icon { @apply opacity-100; color: theme("backgroundColor.brand"); } +.icon--custom { + margin-block-start: -1px; +} + .center-content { display: flex; flex-direction: column; @@ -128,15 +120,7 @@ ul:focus { font-size: var(--calcite-internal-combobox-item-description-font-size); } -:host([selected]), -:host(:hover) { - .description { - color: var(--calcite-color-text-2); - } -} - .short-text { - color: var(--calcite-color-text-3); white-space: nowrap; } @@ -144,6 +128,20 @@ ul:focus { color: var(--calcite-color-text-1); } +:host([selected]) { + .title { + @apply font-medium; + } +} + +.label, +.label:hover { + .description, + .short-text { + @apply text-color-3; + } +} + .title, .description, .short-text { diff --git a/packages/calcite-components/src/components/combobox-item/combobox-item.tsx b/packages/calcite-components/src/components/combobox-item/combobox-item.tsx index 6291e933e87..0e6fc172514 100644 --- a/packages/calcite-components/src/components/combobox-item/combobox-item.tsx +++ b/packages/calcite-components/src/components/combobox-item/combobox-item.tsx @@ -236,7 +236,6 @@ export class ComboboxItem extends LitElement implements InteractiveComponent { `scale--${scale}` as const, - selected: "label--selected", shortText: "short-text", single: "label--single", textContainer: "text-container", diff --git a/packages/calcite-components/src/components/combobox/combobox.e2e.ts b/packages/calcite-components/src/components/combobox/combobox.e2e.ts index 9a19ae3cc1e..217aaca1686 100644 --- a/packages/calcite-components/src/components/combobox/combobox.e2e.ts +++ b/packages/calcite-components/src/components/combobox/combobox.e2e.ts @@ -2099,12 +2099,15 @@ describe("calcite-combobox", () => { it("after click interaction with listbox, user can transition to using keyboard “enter” to toggle selected on/off", async () => { expect(itemNestedLi).toHaveClass(ComboboxItemCSS.active); + const selectedItem = await page.find("calcite-combobox-item#PineNested"); + expect(await selectedItem.getProperty("selected")).toBe(true); + await itemNestedLi.press("Enter"); - expect(itemNestedLi).not.toHaveClass(ComboboxItemCSS.selected); + expect(await selectedItem.getProperty("selected")).toBe(false); expect(itemNestedLi).toHaveClass(ComboboxItemCSS.active); await itemNestedLi.press("Enter"); - expect(itemNestedLi).toHaveClass(ComboboxItemCSS.selected); + expect(await selectedItem.getProperty("selected")).toBe(true); expect(itemNestedLi).toHaveClass(ComboboxItemCSS.active); await element.press("Tab");