Skip to content

Commit

Permalink
feat(combobox): append custom values to top of dropdown (#9817)
Browse files Browse the repository at this point in the history
**Related Issue:**
[#7288](#7288)

## Summary
Update `combobox` to append custom values to top of dropdown list.
  • Loading branch information
aPreciado88 authored and github-actions[bot] committed Jul 30, 2024
1 parent 5d287b9 commit bd55097
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -905,7 +905,7 @@ describe("calcite-combobox", () => {
await input.press("Enter");
await page.waitForChanges();

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

const combobox = await page.find("calcite-combobox");
Expand All @@ -932,14 +932,14 @@ describe("calcite-combobox", () => {
await input.press("Enter");
await page.waitForChanges();

const customValue = await page.find("calcite-combobox-item:first-child");
const item1 = await page.find("calcite-combobox-item#one");
const item2 = await page.find("calcite-combobox-item:last-child");

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

expect((await combobox.getProperty("selectedItems")).length).toBe(1);
expect(await customValue.getProperty("selected")).toBe(true);
expect(await item1.getProperty("selected")).toBe(false);
expect(await item2.getProperty("selected")).toBe(true);
});

it("should auto-select new custom values in multiple selection mode", async () => {
Expand All @@ -960,16 +960,16 @@ describe("calcite-combobox", () => {
await input.press("Escape");
await page.waitForChanges();

const customValue = await page.find("calcite-combobox-item:first-child");
const item1 = await page.find("calcite-combobox-item#one");
const item2 = await page.find("calcite-combobox-item#two");
const item3 = await page.find("calcite-combobox-item:last-child");
const chips = await page.findAll("calcite-combobox >>> calcite-chip");

expect((await combobox.getProperty("selectedItems")).length).toBe(3);
expect(chips[2].textContent).toBe("K");
expect(await customValue.getProperty("selected")).toBe(true);
expect(await item1.getProperty("selected")).toBe(true);
expect(await item2.getProperty("selected")).toBe(true);
expect(await item3.getProperty("selected")).toBe(true);
});
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1292,7 +1292,7 @@ export class Combobox
item.value = value;
item.textLabel = value;
item.selected = true;
this.el.appendChild(item);
this.el.prepend(item);
this.resetText();
if (focus) {
this.setFocus();
Expand Down

0 comments on commit bd55097

Please sign in to comment.