Skip to content

Commit

Permalink
fix(combobox): use heading as fallback for UI labels (#10879)
Browse files Browse the repository at this point in the history
**Related Issue:** #10321 

## Summary

Follow-up from #10855.
  • Loading branch information
jcfranco authored Nov 26, 2024
1 parent 727530c commit 2a1d844
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1106,7 +1106,7 @@ describe("calcite-combobox", () => {
await page.waitForChanges();

const item = await page.find("calcite-combobox-item:first-child");
expect(await item.getProperty("textLabel")).toBe("K");
expect(await item.getProperty("heading")).toBe("K");

const combobox = await page.find("calcite-combobox");

Expand Down Expand Up @@ -1135,7 +1135,7 @@ describe("calcite-combobox", () => {
const customValue = await page.find("calcite-combobox-item:first-child");
const item1 = await page.find("calcite-combobox-item#one");

expect(await customValue.getProperty("textLabel")).toBe("K");
expect(await customValue.getProperty("heading")).toBe("K");

expect((await combobox.getProperty("selectedItems")).length).toBe(1);
expect(await customValue.getProperty("selected")).toBe(true);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1299,7 +1299,7 @@ export class Combobox
}

private addCustomChip(value: string, focus?: boolean): void {
const existingItem = this.items.find((el) => el.textLabel === value);
const existingItem = this.items.find((el) => (el.heading || el.textLabel) === value);
if (existingItem) {
this.toggleSelection(existingItem, true);
} else {
Expand All @@ -1311,7 +1311,7 @@ export class Combobox
"calcite-combobox-item",
);
item.value = value;
item.textLabel = value;
item.heading = value;
item.selected = true;
this.el.prepend(item);
this.resetText();
Expand Down Expand Up @@ -1676,7 +1676,7 @@ export class Combobox
role="option"
tabIndex="-1"
>
{item.textLabel}
{item.heading || item.textLabel}
</li>
));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,5 +45,5 @@ export function isSingleLike(selectionMode: Combobox["selectionMode"]): boolean
}

export function getLabel(item: ComboboxItem["el"]): string {
return item.shortHeading || item.textLabel;
return item.shortHeading || item.heading || item.textLabel;
}

0 comments on commit 2a1d844

Please sign in to comment.