From 850b05573eff189f0f2c0381f8d805dd8eca807f Mon Sep 17 00:00:00 2001 From: hjlarry Date: Sat, 6 Sep 2025 12:01:49 +0800 Subject: [PATCH] add dropdown users list --- .../workflow/header/online-users.tsx | 84 +++++++++++++------ 1 file changed, 57 insertions(+), 27 deletions(-) diff --git a/web/app/components/workflow/header/online-users.tsx b/web/app/components/workflow/header/online-users.tsx index 7f6792d860..f339a75055 100644 --- a/web/app/components/workflow/header/online-users.tsx +++ b/web/app/components/workflow/header/online-users.tsx @@ -1,4 +1,5 @@ 'use client' +import { useState } from 'react' import Avatar from '@/app/components/base/avatar' import { useCollaboration } from '../collaboration/hooks/use-collaboration' import { useStore } from '../store' @@ -6,10 +7,16 @@ import cn from '@/utils/classnames' import { ChevronDown } from '@/app/components/base/icons/src/vender/solid/arrows' import { getUserColor } from '../collaboration/utils/user-color' import Tooltip from '@/app/components/base/tooltip' +import { + PortalToFollowElem, + PortalToFollowElemContent, + PortalToFollowElemTrigger, +} from '@/app/components/base/portal-to-follow-elem' const OnlineUsers = () => { const appId = useStore(s => s.appId) const { onlineUsers } = useCollaboration(appId) + const [dropdownOpen, setDropdownOpen] = useState(false) if (!onlineUsers || onlineUsers.length === 0) return null @@ -53,37 +60,60 @@ const OnlineUsers = () => { ) })} {remainingCount > 0 && ( - - {onlineUsers.slice(maxVisible).map((user, index) => ( -
- {user.username || 'User'} -
- ))} - - } - position="bottom" - triggerMethod="hover" - needsDelay={false} - asChild + -
setDropdownOpen(true)} + onMouseLeave={() => setDropdownOpen(false)} + asChild > - +{remainingCount} -
-
+
+
+ +{remainingCount} +
+ +
+ + setDropdownOpen(true)} + onMouseLeave={() => setDropdownOpen(false)} + className="z-[9999]" + > +
+ {onlineUsers.map((user) => { + const userColor = getUserColor(user.user_id) + return ( +
+ + + {user.username || 'User'} + +
+ ) + })} +
+
+ )} - {remainingCount > 0 && ( - - )} )