Skip to content

🪢 Open source agent evals & observability: Trace, evaluate, and improve LLM applications with one open platform.

fix(ui): support menu forwardref error, memo list of options, keys for separators (#4989)

Marc Klingen4967b2047892
diff --git a/web/src/components/nav/nav-main.tsx b/web/src/components/nav/nav-main.tsx
index 24184a26b0..e9d2712125 100644
--- a/web/src/components/nav/nav-main.tsx
+++ b/web/src/components/nav/nav-main.tsx
@@ -112,20 +112,20 @@ export function NavMain({ items }: { items: NavMainItem[] }) {
</Collapsible>
) : (
<SidebarMenuItem key={item.title}>
- <SidebarMenuButton
- asChild
- tooltip={item.title}
- isActive={item.isActive}
- >
- {item.menuNode ?? (
+ {item.menuNode || (
+ <SidebarMenuButton
+ asChild
+ tooltip={item.title}
+ isActive={item.isActive}
+ >
<Link
href={item.url}
target={item.newTab ? "blank" : undefined}
>
<NavItemContent item={item} />
</Link>
- )}
- </SidebarMenuButton>
+ </SidebarMenuButton>
+ )}
</SidebarMenuItem>
),
)}
diff --git a/web/src/components/nav/support-menu-dropdown.tsx b/web/src/components/nav/support-menu-dropdown.tsx
index eb80c00fb4..f37d1121fc 100644
--- a/web/src/components/nav/support-menu-dropdown.tsx
+++ b/web/src/components/nav/support-menu-dropdown.tsx
@@ -17,7 +17,7 @@ import {
Sparkles,
type LucideIcon,
} from "lucide-react";
-import { type ReactNode } from "react";
+import { useMemo, type ReactNode } from "react";
import {
type UiCustomizationOption,
useUiCustomization,
@@ -40,94 +40,98 @@ type SupportMenuItem = {
customizableHref?: UiCustomizationOption;
};
-export function SupportMenuDropdown() {
+export const SupportMenuDropdown = () => {
const uiCustomization = useUiCustomization();
- const supportMenuItems: (SupportMenuItem | "separator")[] = [
- {
- title: "Ask AI",
- pathname: "https://langfuse.com/docs/ask-ai",
- icon: Sparkles,
- },
- ];
+ const supportMenuItems: (SupportMenuItem | "separator")[] = useMemo(() => {
+ const items: (SupportMenuItem | "separator")[] = [
+ {
+ title: "Ask AI",
+ pathname: "https://langfuse.com/docs/ask-ai",
+ icon: Sparkles,
+ },
+ ];
- const chatVisible = chatIsVisible();
- if (uiCustomization?.supportHref) {
- supportMenuItems.push({
- title: "Support",
- pathname: uiCustomization.supportHref,
- icon: LifeBuoy,
- });
- } else {
- if (chatAvailable) {
- supportMenuItems.push({
- title: "Chat",
- pathname: "#",
- menuNode: (
- <div className="flex items-center gap-2">
- <MessageCircle className="h-4 w-4" />
- <span>Chat</span>
- <Switch
- defaultChecked={chatVisible}
- onClick={(e) => e.stopPropagation()}
- onCheckedChange={(checked) => {
- if (checked) {
- showChat();
- } else {
- hideChat();
- }
- }}
- className="ml-auto"
- />
- </div>
- ),
- icon: MessageCircle,
+ const chatVisible = chatIsVisible();
+ if (uiCustomization?.supportHref) {
+ items.push({
+ title: "Support",
+ pathname: uiCustomization.supportHref,
+ icon: LifeBuoy,
+ });
+ } else {
+ if (chatAvailable) {
+ items.push({
+ title: "Chat",
+ pathname: "#",
+ menuNode: (
+ <div className="flex items-center gap-2">
+ <MessageCircle className="h-4 w-4" />
+ <span>Chat</span>
+ <Switch
+ defaultChecked={chatVisible}
+ onClick={(e) => e.stopPropagation()}
+ onCheckedChange={(checked) => {
+ if (checked) {
+ showChat();
+ } else {
+ hideChat();
+ }
+ }}
+ className="ml-auto"
+ />
+ </div>
+ ),
+ icon: MessageCircle,
+ });
+ }
+ items.push("separator");
+ items.push({
+ title: "GitHub Support",
+ pathname: "https://langfuse.com/gh-support",
+ icon: Github,
+ });
+ items.push({
+ title: "Discord",
+ pathname: "https://langfuse.com/discord",
+ icon: SiDiscord,
});
}
- supportMenuItems.push("separator");
- supportMenuItems.push({
- title: "GitHub Support",
- pathname: "https://langfuse.com/gh-support",
- icon: Github,
- });
- supportMenuItems.push({
- title: "Discord",
- pathname: "https://langfuse.com/discord",
- icon: SiDiscord,
+
+ items.push("separator");
+ items.push({
+ title: "Docs",
+ pathname: "https://langfuse.com/docs",
+ icon: LibraryBig,
+ customizableHref: "documentationHref",
});
- }
+ items.push("separator");
- supportMenuItems.push("separator");
- supportMenuItems.push({
- title: "Docs",
- pathname: "https://langfuse.com/docs",
- icon: LibraryBig,
- customizableHref: "documentationHref",
- });
- supportMenuItems.push("separator");
+ if (uiCustomization?.feedbackHref) {
+ items.push({
+ title: "Feedback",
+ pathname: uiCustomization.feedbackHref,
+ icon: MessageSquarePlus,
+ });
+ } else {
+ items.push(
+ ...[
+ {
+ title: "Feature Request",
+ pathname: "https://langfuse.com/ideas",
+ icon: Lightbulb,
+ },
+ {
+ title: "Report a Bug",
+ pathname: "https://langfuse.com/issues",
+ icon: Bug,
+ },
+ ],
+ );
+ }
- if (uiCustomization?.feedbackHref) {
- supportMenuItems.push({
- title: "Feedback",
- pathname: uiCustomization.feedbackHref,
- icon: MessageSquarePlus,
- });
- } else {
- supportMenuItems.push(
- ...[
- {
- title: "Feature Request",
- pathname: "https://langfuse.com/ideas",
- icon: Lightbulb,
- },
- {
- title: "Report a Bug",
- pathname: "https://langfuse.com/issues",
- icon: Bug,
- },
- ],
- );
- }
+ return items;
+ }, [uiCustomization]);
const { isMobile } = useSidebar();
@@ -144,15 +148,15 @@ export function SupportMenuDropdown() {
align="end"
sideOffset={4}
>
- {supportMenuItems.map((item) => {
+ {supportMenuItems.map((item, index) => {
if (item === "separator") {
- return <DropdownMenuSeparator key="separator" />;
+ return <DropdownMenuSeparator key={`separator-${index}`} />;
}
const url = item.customizableHref
? (uiCustomization?.[item.customizableHref] ?? item.pathname)
: item.pathname;
return (
- <DropdownMenuItem key={item.title} asChild>
+ <DropdownMenuItem key={item.title}>
{item.menuNode ?? (
<a
href={url}
@@ -175,4 +179,4 @@ export function SupportMenuDropdown() {
</DropdownMenuContent>
</DropdownMenu>
);
-}
+};