Skip to content

Commit 355c2e6

Browse files
fix(extension): [LW-10975] add new wallet modal closing on overlay click (#1381)
Co-authored-by: Michael Chappell <7581002+mchappell@users.noreply.github.com>
1 parent b0f4e2e commit 355c2e6

File tree

1 file changed

+22
-10
lines changed
  • apps/browser-extension-wallet/src/views/browser-view/features/multi-wallet

1 file changed

+22
-10
lines changed

apps/browser-extension-wallet/src/views/browser-view/features/multi-wallet/MultiWallet.tsx

Lines changed: 22 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { WalletSetupConfirmationDialogProvider, WalletSetupFlow, WalletSetupFlow
44
import { useBackgroundPage } from '@providers/BackgroundPageProvider';
55
import { walletRoutePaths } from '@routes';
66
import { Modal } from 'antd';
7-
import React from 'react';
7+
import React, { useCallback } from 'react';
88
import { useHistory } from 'react-router-dom';
99
import styles from './MultiWallet.module.scss';
1010
import { WalletOnboardingFlows } from './WalletOnboardingFlows';
@@ -17,20 +17,32 @@ export const MultiWallet = (): JSX.Element => {
1717
const posthogClient = usePostHogClientContext();
1818
const { page, setBackgroundPage } = useBackgroundPage();
1919

20+
const handleOnCancel = useCallback(
21+
(withConfirmationDialog: (callback: () => void) => () => void) => {
22+
withConfirmationDialog(() => {
23+
setBackgroundPage();
24+
history.push(page);
25+
window.location.reload();
26+
})();
27+
},
28+
[history, page, setBackgroundPage]
29+
);
30+
2031
return (
2132
<WalletSetupFlowProvider flow={WalletSetupFlow.ADD_WALLET}>
2233
<WalletSetupConfirmationDialogProvider>
2334
{({ isDialogOpen, withConfirmationDialog, shouldShowDialog$ }) => (
24-
<Modal centered closable={false} footer={null} open={!isDialogOpen} width="100%" className={styles.modal}>
35+
<Modal
36+
centered
37+
closable
38+
footer={null}
39+
open={!isDialogOpen}
40+
width="100%"
41+
className={styles.modal}
42+
onCancel={() => handleOnCancel(withConfirmationDialog)}
43+
>
2544
<div className={styles.closeButton}>
26-
<NavigationButton
27-
icon="cross"
28-
onClick={withConfirmationDialog(() => {
29-
setBackgroundPage();
30-
history.push(page);
31-
window.location.reload();
32-
})}
33-
/>
45+
<NavigationButton icon="cross" onClick={() => handleOnCancel(withConfirmationDialog)} />
3446
</div>
3547
<WalletOnboardingFlows
3648
mergeEventRequired

0 commit comments

Comments
 (0)