diff --git a/frontend/app/element/dropdown.stories.tsx b/frontend/app/element/dropdown.stories.tsx index 456685c0..77fa35f8 100644 --- a/frontend/app/element/dropdown.stories.tsx +++ b/frontend/app/element/dropdown.stories.tsx @@ -40,6 +40,28 @@ export const Test: Story = { setIsDropdownVisible((prev) => !prev); }; + const mapItemsWithClick = (items: any[]) => { + return items.map((item) => ({ + ...item, + onClick: () => { + // Call the original onClick if it exists + if (item.onClick) { + item.onClick(); + } + // Close the dropdown after an item is clicked + setIsDropdownVisible(false); + }, + // Recursively update subItems' onClick handlers + subItems: item.subItems ? mapItemsWithClick(item.subItems) : undefined, + })); + }; + + // Modify args to include updated items with the new onClick behavior + const modifiedArgs = { + ...args, + items: mapItemsWithClick(args.items), + }; + return (