Skip to content
Open
Show file tree
Hide file tree
Changes from all 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
10 changes: 10 additions & 0 deletions packages/pluggableWidgets/combobox-web/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),

## [Unreleased]

### Added

- We added the "No options available" accessibility status message. Screen readers announce it when no options match and "No options text" is empty.

### Changed

- We hid the "Placeholder text" property when the combobox type is set to Boolean, since boolean attributes can never be empty and the placeholder has no effect.
Expand All @@ -14,6 +18,12 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),

- We fixed an issue where pages with many combo boxes became slow to scroll.

- We improved the screen reader experience of the combobox. The arrow icon is no longer announced as an image, and an empty combobox no longer exposes an empty option to screen reader users.

- We fixed an issue where a "No options text" made only of spaces showed an empty option that screen readers could still reach.

- We fixed an issue where the clear and remove value buttons had no accessible name when their aria labels were empty. They now fall back to "Clear selection" and "Remove value".

## [2.10.0] - 2026-09-21

### Fixed
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,12 +116,12 @@ test.describe("combobox-web single selection keyboard navigation", () => {
await expect(combobox.selectedText).toHaveText(caption);
});

test("shows the no options placeholder when the filter matches nothing", async () => {
test("renders no empty option when the filter matches nothing and no text is configured", async () => {
await combobox.open();
await combobox.filter("zzz");

await expect(combobox.options).toHaveCount(0);
await expect(combobox.noOptionsPlaceholder).toHaveCount(1);
await expect(combobox.noOptionsPlaceholder).toHaveCount(0);
await expect(combobox.input).toHaveAttribute("aria-expanded", "true");

await combobox.filter("");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,8 @@ test.describe("combobox-web menu features on the city overview", () => {
// "land" occurs inside a caption but at the start of none.
await combobox.filter("land");
await expect(combobox.options).toHaveCount(0);
await expect(combobox.noOptionsPlaceholder).toHaveCount(1);
// No "no options" text is configured, so no empty option is exposed.
await expect(combobox.noOptionsPlaceholder).toHaveCount(0);
});

test("renders the configured custom content inside every option", async () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ export const preview = (props: ComboboxPreviewProps): ReactElement => {
a11ySelectedValue: props.a11ySelectedValue,
a11yOptionsAvailable: props.a11yOptionsAvailable,
a11yInstructions: props.a11yInstructions,
a11yNoOption: props.noOptionsText
a11yNoOption: props.noOptionsText || props.a11yNoOptions
}
},
menuFooterContent: props.showFooter ? (
Expand Down
10 changes: 7 additions & 3 deletions packages/pluggableWidgets/combobox-web/src/Combobox.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,15 @@ import { MultiSelection } from "./components/MultiSelection/MultiSelection";
import { Placeholder } from "./components/Placeholder";
import { SingleSelection } from "./components/SingleSelection/SingleSelection";
import { SelectionBaseProps } from "./helpers/types";
import { textOrFallback } from "./helpers/utils";
import { useActionEvents } from "./hooks/useActionEvents";
import { useGetSelector } from "./hooks/useGetSelector";

import "./ui/Combobox.scss";

const DEFAULT_CLEAR_SELECTION_LABEL = "Clear selection";
const DEFAULT_REMOVE_VALUE_LABEL = "Remove value";

export default function Combobox(props: ComboboxContainerProps): ReactElement {
const selector = useGetSelector(props);
const actionEvents = useActionEvents({
Expand All @@ -28,15 +32,15 @@ export default function Combobox(props: ComboboxContainerProps): ReactElement {
ariaLabel: props.ariaLabel?.value,
a11yConfig: {
ariaLabels: {
clearSelection: props.clearButtonAriaLabel?.value ?? "",
removeSelection: props.removeValueAriaLabel?.value ?? "",
clearSelection: textOrFallback(props.clearButtonAriaLabel?.value, DEFAULT_CLEAR_SELECTION_LABEL),
removeSelection: textOrFallback(props.removeValueAriaLabel?.value, DEFAULT_REMOVE_VALUE_LABEL),
selectAll: props.selectAllButtonCaption?.value ?? ""
},
a11yStatusMessage: {
a11ySelectedValue: props.a11ySelectedValue?.value ?? "",
a11yOptionsAvailable: props.a11yOptionsAvailable?.value ?? "",
a11yInstructions: props.a11yInstructions?.value ?? "",
a11yNoOption: props.noOptionsText?.value ?? ""
a11yNoOption: textOrFallback(props.noOptionsText?.value, props.a11yNoOptions?.value ?? "")
}
},
menuFooterContent: props.showFooter ? props.menuFooterContent : undefined
Expand Down
8 changes: 8 additions & 0 deletions packages/pluggableWidgets/combobox-web/src/Combobox.xml
Original file line number Diff line number Diff line change
Expand Up @@ -389,6 +389,14 @@
<translation lang="nl_NL">Aantal beschikbare opties:</translation>
</translations>
</property>
<property key="a11yNoOptions" type="textTemplate" required="false">
<caption>No options available</caption>
<description>Announced when no options match and "No options text" is empty.</description>
<translations>
<translation lang="en_US">No options available.</translation>
<translation lang="nl_NL">Geen opties beschikbaar.</translation>
</translations>
</property>
<property key="a11yInstructions" type="textTemplate" required="false">
<caption>Instructions</caption>
<description>Instructions to be read after announcing the status.</description>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,29 @@ describe("Combo box (Association)", () => {
fireEvent.click(clearButton);
expect(defaultProps.attributeAssociation?.value).toEqual([]);
});
it("gives the clear and remove buttons a default name when their labels are empty", async () => {
defaultProps.attributeAssociation = new ReferenceSetValueBuilder().withValue([obj("111"), obj("222")]).build();
defaultProps.selectedItemsStyle = "boxes";
defaultProps.clearButtonAriaLabel = dynamic.available("");
defaultProps.removeValueAriaLabel = dynamic.available(" ");
const component = render(<Combobox {...defaultProps} />);

expect(await component.findByRole("button", { name: "Clear selection" })).toBeInTheDocument();
expect(component.getAllByRole("button", { name: "Remove value" })).toHaveLength(2);
});
it("announces the no-options status message when no options text is empty", async () => {
defaultProps.selectAllButton = false;
defaultProps.optionsSourceAssociationDataSource = list([]);
defaultProps.noOptionsText = dynamic.available("");
defaultProps.a11yNoOptions = dynamic.available("No options available.");
const component = render(<Combobox {...defaultProps} />);
fireEvent.click(await getInput(component));

expect(component.queryAllByRole("option")).toHaveLength(0);
await waitFor(() => {
expect(document.getElementById("a11y-status-message")).toHaveTextContent("No options available.");
});
});
it("selects all items with the Select All button", async () => {
const component = render(<Combobox {...defaultProps} />);
const input = await getInput(component);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,9 @@ exports[`Combo box (Association) renders combobox widget 1`] = `
class="widget-combobox-icon-container"
>
<svg
aria-hidden="true"
class="widget-combobox-clear-button-icon"
focusable="false"
height="14"
viewBox="0 0 32 32"
width="14"
Expand All @@ -62,7 +64,9 @@ exports[`Combo box (Association) renders combobox widget 1`] = `
class="widget-combobox-icon-container"
>
<svg
aria-hidden="true"
class="widget-combobox-down-arrow-icon mx-icon-lined mx-icon-chevron-down"
focusable="false"
height="16"
viewBox="0 0 32 32"
width="16"
Expand Down Expand Up @@ -150,7 +154,9 @@ exports[`Combo box (Association) toggles combobox menu on: input CLICK(focus) /
class="widget-combobox-icon-container"
>
<svg
aria-hidden="true"
class="widget-combobox-clear-button-icon"
focusable="false"
height="14"
viewBox="0 0 32 32"
width="14"
Expand All @@ -172,7 +178,9 @@ exports[`Combo box (Association) toggles combobox menu on: input CLICK(focus) /
class="widget-combobox-icon-container"
>
<svg
aria-hidden="true"
class="widget-combobox-down-arrow-icon mx-icon-lined mx-icon-chevron-down"
focusable="false"
height="16"
viewBox="0 0 32 32"
width="16"
Expand Down Expand Up @@ -260,7 +268,9 @@ exports[`Combo box (Association) toggles combobox menu on: input TOGGLE BUTTON 1
class="widget-combobox-icon-container"
>
<svg
aria-hidden="true"
class="widget-combobox-clear-button-icon"
focusable="false"
height="14"
viewBox="0 0 32 32"
width="14"
Expand All @@ -282,7 +292,9 @@ exports[`Combo box (Association) toggles combobox menu on: input TOGGLE BUTTON 1
class="widget-combobox-icon-container"
>
<svg
aria-hidden="true"
class="widget-combobox-down-arrow-icon mx-icon-lined mx-icon-chevron-down"
focusable="false"
height="16"
viewBox="0 0 32 32"
width="16"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,9 @@ exports[`Combo box (Association) renders combobox widget 1`] = `
class="widget-combobox-icon-container"
>
<svg
aria-hidden="true"
class="widget-combobox-clear-button-icon"
focusable="false"
height="14"
viewBox="0 0 32 32"
width="14"
Expand All @@ -68,7 +70,9 @@ exports[`Combo box (Association) renders combobox widget 1`] = `
class="widget-combobox-icon-container"
>
<svg
aria-hidden="true"
class="widget-combobox-down-arrow-icon mx-icon-lined mx-icon-chevron-down"
focusable="false"
height="16"
viewBox="0 0 32 32"
width="16"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,9 @@ exports[`Combo box (Static values) renders combobox widget 1`] = `
class="widget-combobox-icon-container"
>
<svg
aria-hidden="true"
class="widget-combobox-clear-button-icon"
focusable="false"
height="14"
viewBox="0 0 32 32"
width="14"
Expand All @@ -68,7 +70,9 @@ exports[`Combo box (Static values) renders combobox widget 1`] = `
class="widget-combobox-icon-container"
>
<svg
aria-hidden="true"
class="widget-combobox-down-arrow-icon mx-icon-lined mx-icon-chevron-down"
focusable="false"
height="16"
viewBox="0 0 32 32"
width="16"
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import "@testing-library/jest-dom";
import { render } from "@testing-library/react";
import { DownArrow } from "../icons";

describe("DownArrow", () => {
it("is hidden from assistive technologies", () => {
const { container } = render(<DownArrow />);

const icon = container.querySelector("svg");
expect(icon).toHaveAttribute("aria-hidden", "true");
});
});
11 changes: 10 additions & 1 deletion packages/pluggableWidgets/combobox-web/src/assets/icons.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,14 @@ import { CaptionContent } from "../helpers/utils";
export function ClearButton({ size = 14 }): ReactElement {
return (
<span className="widget-combobox-icon-container">
<svg width={size} height={size} viewBox="0 0 32 32" className="widget-combobox-clear-button-icon">
<svg
width={size}
height={size}
viewBox="0 0 32 32"
className="widget-combobox-clear-button-icon"
aria-hidden="true"
focusable="false"
>
<path
stroke="currentColor"
strokeLinecap="round"
Expand All @@ -27,6 +34,8 @@ export function DownArrow({ isOpen }: { isOpen?: boolean }): ReactElement {
width="16"
height="16"
viewBox="0 0 32 32"
aria-hidden="true"
focusable="false"
>
<path d="M16 23.41L4.29004 11.71L5.71004 10.29L16 20.59L26.29 10.29L27.71 11.71L16 23.41Z" />
</svg>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,12 @@ export function Placeholder(): ReactElement {
);
}

export function NoOptionsPlaceholder(props: PropsWithChildren): ReactElement {
export function NoOptionsPlaceholder(props: { children?: string }): ReactElement | null {
// Blank text would still be reachable as an empty option by screen readers.
if (!props.children?.trim()) {
return null;
}

return (
<li className="widget-combobox-item widget-combobox-no-options" role="option">
{props.children}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import "@testing-library/jest-dom";
import { render } from "@testing-library/react";
import { ComboboxMenuWrapper } from "../ComboboxMenuWrapper";

const baseProps = {
isEmpty: true,
isLoading: false,
isOpen: true,
lazyLoading: false,
loader: null,
getMenuProps: (options?: any) => ({ ...options })
};

describe("ComboboxMenuWrapper empty state", () => {
it("does not expose an empty option when there is no no-options text", () => {
const { container } = render(<ComboboxMenuWrapper {...baseProps} noOptionsText="" />);

expect(container.querySelector('[role="option"]')).toBeNull();
});

it("does not expose an empty option when the no-options text is only whitespace", () => {
const { container } = render(<ComboboxMenuWrapper {...baseProps} noOptionsText=" " />);

expect(container.querySelector('[role="option"]')).toBeNull();
});

it("exposes the no-options text as an option when it is set", () => {
const { getByRole } = render(<ComboboxMenuWrapper {...baseProps} noOptionsText="No options" />);

expect(getByRole("option")).toHaveTextContent("No options");
});
});
4 changes: 4 additions & 0 deletions packages/pluggableWidgets/combobox-web/src/helpers/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@

export const DEFAULT_LIMIT_SIZE = 100;

export function textOrFallback(text: string | undefined, fallback: string): string {
return text?.trim() ? text : fallback;
}

type ValueType = string | Big | boolean | Date | undefined;

export function getSelectedCaptionsPlaceholder(selector: MultiSelector, selectedItems: string[]): string {
Expand Down Expand Up @@ -35,7 +39,7 @@
export function CaptionContent(props: CaptionContentProps): ReactElement {
const { htmlFor, children, onClick } = props;
return createElement(htmlFor == null ? "span" : "label", {
children,

Check warning on line 42 in packages/pluggableWidgets/combobox-web/src/helpers/utils.ts

View workflow job for this annotation

GitHub Actions / Run code quality check

Do not pass 'children' as props
className: "widget-combobox-caption-text",
htmlFor,
onClick: onClick
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@ export interface ComboboxContainerProps {
removeValueAriaLabel?: DynamicValue<string>;
a11ySelectedValue?: DynamicValue<string>;
a11yOptionsAvailable?: DynamicValue<string>;
a11yNoOptions?: DynamicValue<string>;
a11yInstructions?: DynamicValue<string>;
lazyLoading: boolean;
loadingType: LoadingTypeEnum;
Expand Down Expand Up @@ -175,6 +176,7 @@ export interface ComboboxPreviewProps {
removeValueAriaLabel: string;
a11ySelectedValue: string;
a11yOptionsAvailable: string;
a11yNoOptions: string;
a11yInstructions: string;
lazyLoading: boolean;
loadingType: LoadingTypeEnum;
Expand Down
Loading