Skip to content
TypeScript

fix(web): name combobox chip removal targets (#10127)

Alex Southwell55333833ec26
diff --git a/apps/web/src/components/ui/combobox.tsx b/apps/web/src/components/ui/combobox.tsx
index e2253100d2d..d9f09690331 100644
--- a/apps/web/src/components/ui/combobox.tsx
+++ b/apps/web/src/components/ui/combobox.tsx
@@ -352,27 +352,37 @@ function ComboboxChips({
}
function ComboboxChip({ children, ...props }: ComboboxPrimitive.Chip.Props) {
+ const labelId = React.useId();
+
return (
<ComboboxPrimitive.Chip
className="flex items-center rounded-[calc(var(--radius-md)-1px)] bg-accent ps-2 font-medium text-accent-foreground text-sm outline-none sm:text-xs/(--text-xs--line-height) [&_svg:not([class*='size-'])]:size-4 sm:[&_svg:not([class*='size-'])]:size-3.5"
data-slot="combobox-chip"
{...props}
>
- {children}
- <ComboboxChipRemove />
+ <span id={labelId}>{children}</span>
+ <ComboboxChipRemove labelId={labelId} />
</ComboboxPrimitive.Chip>
);
}
-function ComboboxChipRemove(props: ComboboxPrimitive.ChipRemove.Props) {
+function ComboboxChipRemove({
+ labelId,
+ ...props
+}: ComboboxPrimitive.ChipRemove.Props & { labelId: string }) {
+ const removeLabelId = `${labelId}-remove`;
+
return (
<ComboboxPrimitive.ChipRemove
- aria-label="Remove"
+ aria-labelledby={`${removeLabelId} ${labelId}`}
className="h-full shrink-0 cursor-pointer px-1.5 opacity-80 hover:opacity-100 [&_svg:not([class*='size-'])]:size-4 sm:[&_svg:not([class*='size-'])]:size-3.5"
data-slot="combobox-chip-remove"
{...props}
>
- <XIcon />
+ <span id={removeLabelId} className="sr-only">
+ Remove
+ </span>
+ <XIcon aria-hidden="true" />
</ComboboxPrimitive.ChipRemove>
);
}