fix(ui): improve sidebar menu item active state detection

This commit is contained in:
alejandrobailo
2026-01-22 11:58:53 +01:00
parent d4e181855f
commit b06604adcf

View File

@@ -34,7 +34,9 @@ export const MenuItem = ({
highlight,
}: MenuItemProps) => {
const pathname = usePathname();
const isActive = active !== undefined ? active : pathname.startsWith(href);
// Extract only the pathname from href (without query parameters) for comparison
const hrefPathname = href.split("?")[0];
const isActive = active !== undefined ? active : pathname.startsWith(hrefPathname);
// Show tooltip always for Prowler Hub, or when sidebar is collapsed
const showTooltip = label === "Prowler Hub" ? !!tooltip : !isOpen;
@@ -55,8 +57,8 @@ export const MenuItem = ({
<Icon size={18} />
</span>
{isOpen && (
<p className="max-w-[200px] truncate">
{label}
<p className="flex max-w-[200px] items-center truncate">
<span>{label}</span>
{highlight && (
<span className="ml-2 rounded-sm bg-emerald-500 px-1.5 py-0.5 text-[10px] font-semibold text-white">
NEW