diff --git a/web/src/components/features/dropdowns/SaveToCollectionsDropdown.tsx b/web/src/components/features/dropdowns/SaveToCollectionsDropdown.tsx index af6dd6afe..455f99a34 100644 --- a/web/src/components/features/dropdowns/SaveToCollectionsDropdown.tsx +++ b/web/src/components/features/dropdowns/SaveToCollectionsDropdown.tsx @@ -21,22 +21,28 @@ export const SaveToCollectionsDropdown: React.FC<{ const [openCollectionModal, setOpenCollectionModal] = React.useState(false); const [showDropdown, setShowDropdown] = React.useState(false); - const items: DropdownProps['items'] = useMemo( - () => - (collectionsList || []).map((collection) => { - return { - value: collection.id, - label: collection.name, - selected: selectedCollections.some((id) => id === collection.id), - onClick: () => onClickItem(collection), - link: createBusterRoute({ - route: BusterRoutes.APP_COLLECTIONS_ID, - collectionId: collection.id - }) - }; - }), - [collectionsList, selectedCollections] - ); + const items: DropdownProps['items'] = useMemo(() => { + const collectionsItems = (collectionsList || []).map((collection) => { + return { + value: collection.id, + label: collection.name, + selected: selectedCollections.some((id) => id === collection.id), + onClick: () => onClickItem(collection), + link: createBusterRoute({ + route: BusterRoutes.APP_COLLECTIONS_ID, + collectionId: collection.id + }) + }; + }); + + return [ + ...collectionsItems, + { + value: 'new', + label: 'New collection' + } + ]; + }, [collectionsList, selectedCollections]); const onClickItem = useMemoizedFn((collection: BusterCollectionListItem) => { const isSelected = selectedCollections.some((id) => id === collection.id); @@ -63,6 +69,7 @@ export const SaveToCollectionsDropdown: React.FC<{ const onOpenChange = useMemoizedFn((open: boolean) => { setShowDropdown(open); + console.log('open', open); }); const onClick = useMemoizedFn(() => { @@ -84,11 +91,12 @@ export const SaveToCollectionsDropdown: React.FC<{ side="bottom" align="start" menuHeader={'Save to a collection'} - open={showDropdown} onOpenChange={onOpenChange} footerContent={memoizedButton} items={items}> - {children} +
+ {children} +
, + searchLabel: 'Third Item with secondary label', secondaryLabel: 'With secondary label' }, { diff --git a/web/src/components/ui/dropdown/Dropdown.tsx b/web/src/components/ui/dropdown/Dropdown.tsx index 32b401df9..4b86202bb 100644 --- a/web/src/components/ui/dropdown/Dropdown.tsx +++ b/web/src/components/ui/dropdown/Dropdown.tsx @@ -164,9 +164,9 @@ export const DropdownBase = ({ className={cn('max-w-72 min-w-44', className)} align={align} side={side} - footerContent={footerContent}> - {menuHeader && ( - <> + footerContent={footerContent} + headerContent={ + menuHeader && ( ({ onSelectItem={onSelectItem} showIndex={showIndex} /> - - - )} - + ) + }>
{hasShownItem ? ( <> @@ -324,11 +322,12 @@ const DropdownItem = ({ const content = ( <> {icon && !loading && {icon}} - {loading && } +
{label} {secondaryLabel && {secondaryLabel}}
+ {loading && } {shortcut && {shortcut}} {link && ( ({ , React.ComponentPropsWithoutRef & { footerContent?: React.ReactNode; + headerContent?: React.ReactNode; } ->(({ className, children, sideOffset = 4, footerContent, ...props }, ref) => { - const NodeWrapper = footerContent ? 'div' : 'span'; - const nodeWrapperProps = footerContent ? { className: 'p-2' } : { className: '' }; - +>(({ className, children, sideOffset = 4, footerContent, headerContent, ...props }, ref) => { return ( - {children} - {footerContent &&
{footerContent}
} + {headerContent && ( +
+
{headerContent}
+
+
+ )} +
{children}
+ {footerContent &&
{footerContent}
} ); @@ -102,6 +106,7 @@ const DropdownMenuItem = React.forwardRef< className={cn( 'relative flex cursor-pointer items-center gap-2 rounded-sm px-2 py-1.5 text-base outline-none select-none data-[disabled]:pointer-events-none data-[disabled]:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0', 'focus:bg-item-hover focus:text-foreground', + 'dropdown-item mx-1 [&.dropdown-item:first-child]:mt-1! [&.dropdown-item:has(+.dropdown-separator)]:mb-1 [&.dropdown-item:has(~.dropdown-separator)]:mt-1 [&.dropdown-item:last-child]:mb-1!', inset && 'pl-8', truncate && 'overflow-hidden', 'group', @@ -123,7 +128,8 @@ const itemClass = cn( 'focus:bg-item-hover focus:text-foreground', 'relative flex cursor-pointer items-center rounded-sm py-1.5 text-sm outline-none select-none', 'data-[disabled]:pointer-events-none data-[disabled]:opacity-50', - 'gap-1.5' + 'gap-1.5', + 'mx-1 dropdown-item [&.dropdown-item:has(+.dropdown-separator)]:mb-1 [&.dropdown-item:has(~.dropdown-separator)]:mt-1 [&.dropdown-item:first-child]:mt-1! [&.dropdown-item:last-child]:mb-1!' ); const DropdownMenuCheckboxItemSingle = React.forwardRef<