Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(combobox): fix accessibility when an item's heading or label changes #11289

Merged
merged 7 commits into from
Jan 14, 2025
Merged
Show file tree
Hide file tree
Changes from 6 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
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { describe } from "vitest";
import { describe, it, expect } from "vitest";
import { newE2EPage } from "@arcgis/lumina-compiler/puppeteerTesting";
import { defaults, disabled, hidden, reflects, renders, slots } from "../../tests/commonTests";
import { SLOTS } from "./resources";

Expand Down Expand Up @@ -46,4 +47,43 @@ describe("calcite-combobox-item", () => {
describe("disabled", () => {
disabled("calcite-combobox-item", { focusTarget: "none" });
});

it("should emit calciteInternalComboboxItemChange", async () => {
const page = await newE2EPage();
driskull marked this conversation as resolved.
Show resolved Hide resolved

await page.setContent("<calcite-combobox-item></calcite-combobox-item>");

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

const eventSpy = await element.spyOnEvent("calciteInternalComboboxItemChange");

await page.waitForChanges();

expect(eventSpy).not.toHaveReceivedEvent();

element.setProperty("selected", true);
await page.waitForChanges();

expect(eventSpy).toHaveReceivedEventTimes(1);

element.setProperty("textLabel", "hello");
await page.waitForChanges();

expect(eventSpy).toHaveReceivedEventTimes(2);

element.setProperty("heading", "hello");
await page.waitForChanges();

expect(eventSpy).toHaveReceivedEventTimes(3);

element.setProperty("label", "hello");
await page.waitForChanges();

expect(eventSpy).toHaveReceivedEventTimes(4);

element.setProperty("disabled", true);
await page.waitForChanges();

expect(eventSpy).toHaveReceivedEventTimes(5);
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,9 @@ export class ComboboxItem extends LitElement implements InteractiveComponent {
if (
(changes.has("disabled") && this.hasUpdated) ||
(changes.has("selected") && this.hasUpdated) ||
(changes.has("textLabel") && this.hasUpdated)
(changes.has("textLabel") && this.hasUpdated) ||
(changes.has("heading") && this.hasUpdated) ||
(changes.has("label") && this.hasUpdated)
) {
this.calciteInternalComboboxItemChange.emit();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1679,6 +1679,7 @@ export class Combobox
private renderListBoxOptions(): JsxNode {
return this.filteredItems.map((item) => (
<li
ariaLabel={item.label}
ariaSelected={item.selected}
id={item.guid ? `${itemUidPrefix}${item.guid}` : null}
role="option"
Expand Down
Loading