Skip to content

Commit 19d7c43

Browse files
anveshmekalabenelan
authored andcommitted
feat(combobox-item): update interactive state (#11647)
**Related Issue:** #11646 ## Summary No longer changes `description` & `heading` color when hovered.
1 parent c05ba8e commit 19d7c43

File tree

4 files changed

+35
-39
lines changed

4 files changed

+35
-39
lines changed

packages/calcite-components/src/components/combobox-item/combobox-item.scss

+30-32
Original file line numberDiff line numberDiff line change
@@ -71,25 +71,22 @@ ul:focus {
7171
@apply cursor-default;
7272
}
7373

74-
// selected state
75-
.label--selected {
76-
@apply text-color-1;
77-
78-
.title {
79-
@apply font-medium;
80-
}
81-
}
82-
8374
.label--active {
8475
@apply focus-inset;
8576
}
8677

87-
.label:hover,
78+
:host([selected]) .label,
8879
.label:active {
89-
@apply text-color-1
90-
bg-foreground-2
91-
no-underline
92-
shadow-none;
80+
@apply text-color-1;
81+
82+
.description,
83+
.short-text {
84+
@apply text-color-2;
85+
}
86+
}
87+
88+
.label:hover {
89+
@apply text-color-1 bg-foreground-2;
9390
}
9491

9592
.label:active {
@@ -101,22 +98,17 @@ ul:focus {
10198
opacity-0
10299
duration-150
103100
ease-in-out;
104-
color: theme("borderColor.color.1");
105-
}
106-
107-
.icon--custom {
108-
margin-block-start: -1px;
109-
}
110-
111-
.icon--selected {
112-
@apply text-color-1;
113101
}
114102

115-
.label--selected .icon {
103+
:host([selected]) .icon {
116104
@apply opacity-100;
117105
color: theme("backgroundColor.brand");
118106
}
119107

108+
.icon--custom {
109+
margin-block-start: -1px;
110+
}
111+
120112
.center-content {
121113
display: flex;
122114
flex-direction: column;
@@ -128,22 +120,28 @@ ul:focus {
128120
font-size: var(--calcite-internal-combobox-item-description-font-size);
129121
}
130122

131-
:host([selected]),
132-
:host(:hover) {
133-
.description {
134-
color: var(--calcite-color-text-2);
135-
}
136-
}
137-
138123
.short-text {
139-
color: var(--calcite-color-text-3);
140124
white-space: nowrap;
141125
}
142126

143127
.title {
144128
color: var(--calcite-color-text-1);
145129
}
146130

131+
:host([selected]) {
132+
.title {
133+
@apply font-medium;
134+
}
135+
}
136+
137+
.label,
138+
.label:hover {
139+
.description,
140+
.short-text {
141+
@apply text-color-3;
142+
}
143+
}
144+
147145
.title,
148146
.description,
149147
.short-text {

packages/calcite-components/src/components/combobox-item/combobox-item.tsx

-3
Original file line numberDiff line numberDiff line change
@@ -236,7 +236,6 @@ export class ComboboxItem extends LitElement implements InteractiveComponent {
236236
<calcite-icon
237237
class={{
238238
[CSS.custom]: !!this.icon,
239-
[CSS.iconSelected]: this.icon && this.selected,
240239
}}
241240
flipRtl={this.iconFlipRtl}
242241
icon={this.icon || iconPath}
@@ -251,7 +250,6 @@ export class ComboboxItem extends LitElement implements InteractiveComponent {
251250
<calcite-icon
252251
class={{
253252
[CSS.icon]: true,
254-
[CSS.iconSelected]: this.selected,
255253
}}
256254
flipRtl={this.iconFlipRtl}
257255
icon={icon}
@@ -288,7 +286,6 @@ export class ComboboxItem extends LitElement implements InteractiveComponent {
288286

289287
const classes = {
290288
[CSS.label]: true,
291-
[CSS.selected]: this.selected,
292289
[CSS.active]: this.active,
293290
[CSS.single]: isSingleSelect,
294291
};

packages/calcite-components/src/components/combobox-item/resources.ts

-2
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,8 @@ export const CSS = {
77
custom: "icon--custom",
88
description: "description",
99
icon: "icon",
10-
iconSelected: "icon--selected",
1110
label: "label",
1211
scale: (scale: Scale) => `scale--${scale}` as const,
13-
selected: "label--selected",
1412
shortText: "short-text",
1513
single: "label--single",
1614
textContainer: "text-container",

packages/calcite-components/src/components/combobox/combobox.e2e.ts

+5-2
Original file line numberDiff line numberDiff line change
@@ -2099,12 +2099,15 @@ describe("calcite-combobox", () => {
20992099
it("after click interaction with listbox, user can transition to using keyboard “enter” to toggle selected on/off", async () => {
21002100
expect(itemNestedLi).toHaveClass(ComboboxItemCSS.active);
21012101

2102+
const selectedItem = await page.find("calcite-combobox-item#PineNested");
2103+
expect(await selectedItem.getProperty("selected")).toBe(true);
2104+
21022105
await itemNestedLi.press("Enter");
2103-
expect(itemNestedLi).not.toHaveClass(ComboboxItemCSS.selected);
2106+
expect(await selectedItem.getProperty("selected")).toBe(false);
21042107
expect(itemNestedLi).toHaveClass(ComboboxItemCSS.active);
21052108

21062109
await itemNestedLi.press("Enter");
2107-
expect(itemNestedLi).toHaveClass(ComboboxItemCSS.selected);
2110+
expect(await selectedItem.getProperty("selected")).toBe(true);
21082111
expect(itemNestedLi).toHaveClass(ComboboxItemCSS.active);
21092112

21102113
await element.press("Tab");

0 commit comments

Comments
 (0)