Change more menu link/action handling
This commit is contained in:
parent
7c267caa0a
commit
e9ead7cc9b
@ -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));
|
||||
}
|
||||
}
|
||||
}}
|
||||
>
|
||||
|
||||
Loading…
Reference in New Issue
Block a user