From 0cec66b3bbbcc0e6fa56e28a9168bfff9ed4d192 Mon Sep 17 00:00:00 2001 From: MehdiBouzouaya <115163697+MehdiBouzouaya@users.noreply.github.com> Date: Wed, 14 May 2025 00:31:21 +0200 Subject: [PATCH] Fix: Add missing key prop to context menu items to avoid React warning (#9202) --- app/components/ContextMenu/Template.tsx | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/app/components/ContextMenu/Template.tsx b/app/components/ContextMenu/Template.tsx index 9dafb79759..1050203c19 100644 --- a/app/components/ContextMenu/Template.tsx +++ b/app/components/ContextMenu/Template.tsx @@ -138,7 +138,7 @@ function Template({ items, actions, context, showIcons, ...menu }: Props) { as={Link} id={`${item.title}-${index}`} to={item.to} - key={index} + key={`${item.type}-${item.title}-${index}`} disabled={item.disabled} selected={item.selected} icon={showIcons !== false ? item.icon : undefined} @@ -154,7 +154,7 @@ function Template({ items, actions, context, showIcons, ...menu }: Props) { @@ -185,18 +185,24 @@ function Template({ items, actions, context, showIcons, ...menu }: Props) { ); return item.tooltip ? ( - +
{menuItem}
) : ( - <>{menuItem} + + {menuItem} + ); } if (item.type === "submenu") { return ( ; + return ; } if (item.type === "heading") { - return
{item.title}
; + return ( +
{item.title}
+ ); } const _exhaustiveCheck: never = item;