down arrow works for search

This commit is contained in:
Nate Kelley 2025-04-03 16:36:32 -06:00
parent 55bdd865c1
commit c1eeb88c3c
No known key found for this signature in database
GPG Key ID: FD90372AB8D98B4F
2 changed files with 25 additions and 0 deletions

View File

@ -446,6 +446,23 @@ export const WithLinks: Story = {
} }
}; };
export const WithManyItemsToSearch: Story = {
args: {
menuHeader: 'Search items...',
items: [
...Array.from({ length: 100 }).map(() => {
const product = faker.commerce.productAdjective() + ' ' + faker.commerce.product();
return {
value: product + ' ' + faker.string.uuid(),
label: product
};
})
],
onSelect: fn(),
children: <Button>Menu with Many Items</Button>
}
};
// Interactive example with links and multiple selection // Interactive example with links and multiple selection
export const WithLinksAndMultipleSelection: Story = { export const WithLinksAndMultipleSelection: Story = {
render: () => { render: () => {

View File

@ -585,6 +585,14 @@ const DropdownMenuHeaderSearch = <T,>({
e.preventDefault(); e.preventDefault();
const index = parseInt(e.key); const index = parseInt(e.key);
onSelectItem?.(index); onSelectItem?.(index);
} else if (e.key === 'ArrowDown') {
// Find the first dropdown item and focus it
const menuItems = document.querySelectorAll('[role="menuitem"]');
if (menuItems.length > 0) {
e.preventDefault();
e.stopPropagation();
(menuItems[0] as HTMLElement).focus();
}
} else { } else {
e.stopPropagation(); e.stopPropagation();
} }