From 84d7b458d6669876f861eb41e6c64f9d4a81b71d Mon Sep 17 00:00:00 2001 From: Cyril Date: Tue, 3 Feb 2026 13:50:04 +0100 Subject: [PATCH] Fix AI combobox aria-activedescendant --- packages/ariakit/src/input/TextInput.tsx | 2 ++ packages/mantine/src/form/TextInput.tsx | 2 ++ packages/react/src/editor/ComponentsContext.tsx | 1 + packages/shadcn/src/form/TextInput.tsx | 2 ++ .../xl-ai/src/components/AIMenu/PromptSuggestionMenu.tsx | 6 ++++++ 5 files changed, 13 insertions(+) diff --git a/packages/ariakit/src/input/TextInput.tsx b/packages/ariakit/src/input/TextInput.tsx index d4b9817f4a..555961faf0 100644 --- a/packages/ariakit/src/input/TextInput.tsx +++ b/packages/ariakit/src/input/TextInput.tsx @@ -25,6 +25,7 @@ export const TextInput = forwardRef< onChange, onSubmit, autoComplete, + "aria-activedescendant": ariaActivedescendant, rightSection, ...rest } = props; @@ -52,6 +53,7 @@ export const TextInput = forwardRef< onChange={onChange} onSubmit={onSubmit} autoComplete={autoComplete} + aria-activedescendant={ariaActivedescendant} /> {rightSection} diff --git a/packages/mantine/src/form/TextInput.tsx b/packages/mantine/src/form/TextInput.tsx index b781073588..30fac619d2 100644 --- a/packages/mantine/src/form/TextInput.tsx +++ b/packages/mantine/src/form/TextInput.tsx @@ -22,6 +22,7 @@ export const TextInput = forwardRef< onChange, onSubmit, autoComplete, + "aria-activedescendant": ariaActivedescendant, rightSection, ...rest } = props; @@ -49,6 +50,7 @@ export const TextInput = forwardRef< onChange={onChange} onSubmit={onSubmit} autoComplete={autoComplete} + aria-activedescendant={ariaActivedescendant} /> ); }); diff --git a/packages/react/src/editor/ComponentsContext.tsx b/packages/react/src/editor/ComponentsContext.tsx index 2eb161d828..3b95ad7ffc 100644 --- a/packages/react/src/editor/ComponentsContext.tsx +++ b/packages/react/src/editor/ComponentsContext.tsx @@ -272,6 +272,7 @@ export type ComponentProps = { onChange: (event: ChangeEvent) => void; onSubmit?: () => void; autoComplete?: HTMLInputAutoCompleteAttribute; + "aria-activedescendant"?: string; }; }; Menu: { diff --git a/packages/shadcn/src/form/TextInput.tsx b/packages/shadcn/src/form/TextInput.tsx index 3f8acf45ee..d6b979e0c4 100644 --- a/packages/shadcn/src/form/TextInput.tsx +++ b/packages/shadcn/src/form/TextInput.tsx @@ -23,6 +23,7 @@ export const TextInput = forwardRef< onChange, onSubmit, autoComplete, + "aria-activedescendant": ariaActivedescendant, rightSection, // TODO: add rightSection ...rest } = props; @@ -58,6 +59,7 @@ export const TextInput = forwardRef< onChange={onChange} onSubmit={onSubmit} ref={ref} + aria-activedescendant={ariaActivedescendant} /> {rightSection} diff --git a/packages/xl-ai/src/components/AIMenu/PromptSuggestionMenu.tsx b/packages/xl-ai/src/components/AIMenu/PromptSuggestionMenu.tsx index b18e423a8a..28987629e7 100644 --- a/packages/xl-ai/src/components/AIMenu/PromptSuggestionMenu.tsx +++ b/packages/xl-ai/src/components/AIMenu/PromptSuggestionMenu.tsx @@ -67,6 +67,11 @@ export const PromptSuggestionMenu = (props: PromptSuggestionMenuProps) => { const { selectedIndex, setSelectedIndex, handler } = useSuggestionMenuKeyboardHandler(items, (item) => item.onItemClick()); + const activeDescendantId = + items.length > 0 && selectedIndex >= 0 && selectedIndex < items.length + ? `bn-suggestion-menu-item-${selectedIndex}` + : undefined; + const handleKeyDown = useCallback( (event: KeyboardEvent) => { // TODO: handle backspace to close @@ -107,6 +112,7 @@ export const PromptSuggestionMenu = (props: PromptSuggestionMenuProps) => { onChange={handleChange} autoComplete={"off"} rightSection={props.rightSection} + aria-activedescendant={activeDescendantId} />