Skip to content

Commit 9fc7b7d

Browse files
committed
fix(neuron-ui): disable the submit button when it's sending
1 parent a8c9543 commit 9fc7b7d

1 file changed

Lines changed: 6 additions & 3 deletions

File tree

  • packages/neuron-ui/src/components/PasswordRequest

packages/neuron-ui/src/components/PasswordRequest/index.tsx

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import { priceToFee, CKBToShannonFormatter } from 'utils/formatters'
88

99
const PasswordRequest = ({
1010
app: {
11-
send: { txID, outputs, description, price, cycles },
11+
send: { txID, outputs, description, price, cycles, loading: isSending },
1212
passwordRequest: { walletID = '', actionType = null, password = '' },
1313
},
1414
settings: { wallets = [] },
@@ -27,6 +27,9 @@ const PasswordRequest = ({
2727
const onConfirm = useCallback(() => {
2828
switch (actionType) {
2929
case 'send': {
30+
if (isSending) {
31+
break
32+
}
3033
sendTransaction({
3134
id: txID,
3235
walletID,
@@ -58,7 +61,7 @@ const PasswordRequest = ({
5861
break
5962
}
6063
}
61-
}, [dispatch, walletID, password, actionType, txID, description, outputs, cycles, price, history])
64+
}, [dispatch, walletID, password, actionType, txID, description, outputs, cycles, price, history, isSending])
6265

6366
const onChange = useCallback(
6467
(_e, value?: string) => {
@@ -100,7 +103,7 @@ const PasswordRequest = ({
100103
<TextField value={password} type="password" onChange={onChange} autoFocus onKeyPress={onKeyPress} />
101104
<Stack horizontalAlign="end" horizontal tokens={{ childrenGap: 15 }}>
102105
<DefaultButton onClick={onDismiss}>{t('common.cancel')}</DefaultButton>
103-
<PrimaryButton onClick={onConfirm} disabled={!password}>
106+
<PrimaryButton onClick={onConfirm} disabled={!password || (actionType === 'send' && isSending)}>
104107
{t('common.confirm')}
105108
</PrimaryButton>
106109
</Stack>

0 commit comments

Comments
 (0)