Skip to content

Commit dc4e0dd

Browse files
authored
fix(accessibility): ai combobox aria-activedescendant (#2413)
1 parent c20051a commit dc4e0dd

File tree

5 files changed

+13
-0
lines changed

5 files changed

+13
-0
lines changed

packages/ariakit/src/input/TextInput.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ export const TextInput = forwardRef<
2525
onChange,
2626
onSubmit,
2727
autoComplete,
28+
"aria-activedescendant": ariaActivedescendant,
2829
rightSection,
2930
...rest
3031
} = props;
@@ -52,6 +53,7 @@ export const TextInput = forwardRef<
5253
onChange={onChange}
5354
onSubmit={onSubmit}
5455
autoComplete={autoComplete}
56+
aria-activedescendant={ariaActivedescendant}
5557
/>
5658
{rightSection}
5759
</div>

packages/mantine/src/form/TextInput.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ export const TextInput = forwardRef<
2222
onChange,
2323
onSubmit,
2424
autoComplete,
25+
"aria-activedescendant": ariaActivedescendant,
2526
rightSection,
2627
...rest
2728
} = props;
@@ -49,6 +50,7 @@ export const TextInput = forwardRef<
4950
onChange={onChange}
5051
onSubmit={onSubmit}
5152
autoComplete={autoComplete}
53+
aria-activedescendant={ariaActivedescendant}
5254
/>
5355
);
5456
});

packages/react/src/editor/ComponentsContext.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -273,6 +273,7 @@ export type ComponentProps = {
273273
onChange: (event: ChangeEvent<HTMLInputElement>) => void;
274274
onSubmit?: () => void;
275275
autoComplete?: HTMLInputAutoCompleteAttribute;
276+
"aria-activedescendant"?: string;
276277
};
277278
};
278279
Menu: {

packages/shadcn/src/form/TextInput.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ export const TextInput = forwardRef<
2323
onChange,
2424
onSubmit,
2525
autoComplete,
26+
"aria-activedescendant": ariaActivedescendant,
2627
rightSection, // TODO: add rightSection
2728
...rest
2829
} = props;
@@ -58,6 +59,7 @@ export const TextInput = forwardRef<
5859
onChange={onChange}
5960
onSubmit={onSubmit}
6061
ref={ref}
62+
aria-activedescendant={ariaActivedescendant}
6163
/>
6264
</div>
6365
{rightSection}

packages/xl-ai/src/components/AIMenu/PromptSuggestionMenu.tsx

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,11 @@ export const PromptSuggestionMenu = (props: PromptSuggestionMenuProps) => {
6868
const { selectedIndex, setSelectedIndex, handler } =
6969
useSuggestionMenuKeyboardHandler(items, (item) => item.onItemClick());
7070

71+
const activeDescendantId =
72+
items.length > 0 && selectedIndex >= 0 && selectedIndex < items.length
73+
? `bn-suggestion-menu-item-${selectedIndex}`
74+
: undefined;
75+
7176
const handleKeyDown = useCallback(
7277
(event: KeyboardEvent) => {
7378
// TODO: handle backspace to close
@@ -108,6 +113,7 @@ export const PromptSuggestionMenu = (props: PromptSuggestionMenuProps) => {
108113
onChange={handleChange}
109114
autoComplete={"off"}
110115
rightSection={props.rightSection}
116+
aria-activedescendant={activeDescendantId}
111117
/>
112118
</Components.Generic.Form.Root>
113119
{items.length > 0 && (

0 commit comments

Comments
 (0)