Skip to content

Commit b8d38ed

Browse files
minato32elena-zhkernelwhisperer
authored
fix: reset trade confirm state on unmount to allow surplus modal on account pages (#7213)
Co-authored-by: Elena <70885163+elena-zh@users.noreply.github.com> Co-authored-by: kernelwhisperer <hello@danielconstantin.net>
1 parent 891fb5c commit b8d38ed

1 file changed

Lines changed: 10 additions & 1 deletion

File tree

apps/cowswap-frontend/src/modules/trade/containers/TradeWidget/TradeWidgetModals.tsx

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
/* eslint-disable complexity */
21
import { ReactNode, useCallback, useEffect, useRef } from 'react'
32

43
import { usePrevious } from '@cowprotocol/common-hooks'
@@ -106,6 +105,16 @@ export function TradeWidgetModals({
106105

107106
const error = tokenListAddingError || approveError || confirmError
108107

108+
/**
109+
* Reset trade confirm state on unmount so SurplusModalSetup
110+
* doesn't see stale isOpen/transactionHash after navigation
111+
*/
112+
useEffect(() => {
113+
return () => {
114+
closeTradeConfirm()
115+
}
116+
}, [closeTradeConfirm])
117+
109118
/**
110119
* Close all modals besides auto-import on account change
111120
*/

0 commit comments

Comments
 (0)