Skip to content

Commit 359591d

Browse files
authored
fix(twap): stay on Signing tab after placing a TWAP order (#7730)
Closes #6864
1 parent afcc4dc commit 359591d

2 files changed

Lines changed: 10 additions & 6 deletions

File tree

apps/cowswap-frontend/src/modules/ordersTable/hooks/url/useValidatePageUrlParams.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,12 @@ export function useValidatePageUrlParams(
2525
(pagesCount > 0 && currentPageNumber > pagesCount) ||
2626
currentPageNumber < 1 ||
2727
currentPageNumber !== params.pageNumber
28-
const shouldResetTabId = currentTabId !== params.tabId
28+
// Only normalize the tab when the URL has no valid tab.
29+
// `currentTabId` may transiently differ from a valid `params.tabId` because of the
30+
// empty-tab fallback in `useCurrentTab` (e.g. a freshly placed order has not reached
31+
// the Signing list yet). Rewriting the URL in that case would permanently bounce the
32+
// user off the tab they were explicitly navigated to.
33+
const shouldResetTabId = !params.tabId
2934

3035
if (shouldResetPageNumber || shouldResetTabId) {
3136
navigate(

apps/cowswap-frontend/src/modules/twap/hooks/useCreateTwapOrder.tsx

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import { useCowAnalytics } from '@cowprotocol/analytics'
55
import { OrderKind } from '@cowprotocol/cow-sdk'
66
import { CurrencyAmount, Token } from '@cowprotocol/currency'
77
import { UiOrderType } from '@cowprotocol/types'
8-
import { useIsSmartContractWallet, useSendBatchTransactions, useWalletInfo } from '@cowprotocol/wallet'
8+
import { useSendBatchTransactions, useWalletInfo } from '@cowprotocol/wallet'
99
import { WidgetHookEvents } from '@cowprotocol/widget-lib'
1010

1111
import { Nullish } from 'types'
@@ -58,7 +58,6 @@ interface TwapOrderEvent extends TwapAnalyticsEvent {
5858
// eslint-disable-next-line max-lines-per-function, @typescript-eslint/explicit-function-return-type
5959
export function useCreateTwapOrder() {
6060
const { chainId, account } = useWalletInfo()
61-
const isSmartContractWallet = useIsSmartContractWallet()
6261
const twapOrder = useTwapOrder()
6362
const addTwapOrderToList = useSetAtom(addTwapOrderToListAtom)
6463
const navigateToOrdersTableTab = useNavigateToOrdersTableTab()
@@ -215,8 +214,9 @@ export function useCreateTwapOrder() {
215214

216215
// TODO: Clear filters if the new order is not visible before navigating.
217216

218-
// Navigate to open orders after successful placement
219-
navigateToOrdersTableTab(isSmartContractWallet ? OrderTabId.signing : OrderTabId.open)
217+
// A freshly placed TWAP order is always in WaitSigning until the Safe/SC owners
218+
// sign it, so navigate to the Signing tab (not Open) regardless of wallet type.
219+
navigateToOrdersTableTab(OrderTabId.signing)
220220
} catch (error) {
221221
console.error('[useCreateTwapOrder] error', error)
222222
const errorMessage = getErrorMessage(error)
@@ -244,7 +244,6 @@ export function useCreateTwapOrder() {
244244
sendTwapConversionAnalytics,
245245
tradeFlowAnalytics,
246246
navigateToOrdersTableTab,
247-
isSmartContractWallet,
248247
],
249248
)
250249
}

0 commit comments

Comments
 (0)