mirror of https://github.com/buster-so/buster.git
down arrow works for search
This commit is contained in:
parent
55bdd865c1
commit
c1eeb88c3c
|
@ -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: () => {
|
||||||
|
|
|
@ -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();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue