From e9ead7cc9b7f2b96a8e4c236f68e9efc3af5165f Mon Sep 17 00:00:00 2001 From: Sam Becker Date: Tue, 16 Jul 2024 11:17:31 -0500 Subject: [PATCH] Change more menu link/action handling --- src/components/more/MoreMenuItem.tsx | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/src/components/more/MoreMenuItem.tsx b/src/components/more/MoreMenuItem.tsx index ab864291..bc82578b 100644 --- a/src/components/more/MoreMenuItem.tsx +++ b/src/components/more/MoreMenuItem.tsx @@ -42,20 +42,21 @@ export default function MoreMenuItem({ ? 'cursor-not-allowed opacity-50' : 'cursor-pointer', )} - onClick={e => { + onClick={async e => { if (shouldPreventDefault) { e.preventDefault(); } + if (action) { + const result = action(); + if (result instanceof Promise) { + setIsLoading(true); + await result.finally(() => setIsLoading(false)); + } + } if (href && href !== pathname) { if (Boolean(hrefDownloadName)) { window.open(href, '_blank'); } else { startTransition(() => router.push(href)); } - } else { - const result = action?.(); - if (result instanceof Promise) { - setIsLoading(true); - result.finally(() => setIsLoading(false)); - } } }} >