diff --git a/ui/pages/confirmations/hooks/useConfirmationNavigation.test.ts b/ui/pages/confirmations/hooks/useConfirmationNavigation.test.ts index 9804e14a0e00..f832b451572f 100644 --- a/ui/pages/confirmations/hooks/useConfirmationNavigation.test.ts +++ b/ui/pages/confirmations/hooks/useConfirmationNavigation.test.ts @@ -116,6 +116,19 @@ describe('useConfirmationNavigation', () => { ); }); + it('does not navigate to template route if approval flow and pending approval', () => { + const result = renderHook(ApprovalType.Transaction, undefined, [ + {} as never, + ]); + + result.navigateToId(APPROVAL_ID_MOCK); + + expect(history.replace).toHaveBeenCalledTimes(1); + expect(history.replace).toHaveBeenCalledWith( + `${CONFIRM_TRANSACTION_ROUTE}/${APPROVAL_ID_MOCK}`, + ); + }); + it('navigates to connect route', () => { const result = renderHook(ApprovalType.WalletRequestPermissions); diff --git a/ui/pages/confirmations/hooks/useConfirmationNavigation.ts b/ui/pages/confirmations/hooks/useConfirmationNavigation.ts index 95bc1d93cd34..ef081c6497c9 100644 --- a/ui/pages/confirmations/hooks/useConfirmationNavigation.ts +++ b/ui/pages/confirmations/hooks/useConfirmationNavigation.ts @@ -76,12 +76,14 @@ export function navigateToConfirmation( hasApprovalFlows: boolean, history: ReturnType, ) { - if (hasApprovalFlows) { + const hasNoConfirmations = confirmations?.length <= 0 || !confirmationId; + + if (hasApprovalFlows && hasNoConfirmations) { history.replace(`${CONFIRMATION_V_NEXT_ROUTE}`); return; } - if (confirmations?.length <= 0 || !confirmationId) { + if (hasNoConfirmations) { return; } diff --git a/ui/pages/home/home.component.js b/ui/pages/home/home.component.js index 3daed446261a..59dd0419f503 100644 --- a/ui/pages/home/home.component.js +++ b/ui/pages/home/home.component.js @@ -315,9 +315,9 @@ export default class Home extends PureComponent { history.push(PREPARE_SWAP_ROUTE); } else if (canRedirect && haveBridgeQuotes) { history.push(CROSS_CHAIN_SWAP_ROUTE + PREPARE_SWAP_ROUTE); - } else if (pendingApprovals.length) { + } else if (pendingApprovals.length || hasApprovalFlows) { navigateToConfirmation( - pendingApprovals[0].id, + pendingApprovals?.[0]?.id, pendingApprovals, hasApprovalFlows, history,