Skip to content

Commit d483b76

Browse files
authored
Merge pull request #152 from oasisprotocol/ml/move/fix-transfer-more
move: Fix transfer more btn on withdraw flow
2 parents 1027e8e + 6e357bd commit d483b76

File tree

2 files changed

+13
-5
lines changed

2 files changed

+13
-5
lines changed

move/src/useWithdraw.ts

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,9 @@ import { useGenerateSapphireAccount } from './withdraw/useGenerateSapphireAccoun
88
import { minimalWithdrawableAmount, withdrawToConsensus } from './withdraw/withdrawToConsensus'
99

1010
// Use global variable here, due to step4 using different context(not in sync with react hooks)
11-
let isInputMode = true
12-
const setIsInputMode = (_isInputMode: boolean) => {
13-
isInputMode = _isInputMode
11+
let isInputModeGlobal = true
12+
const setIsInputModeGlobal = (_isInputMode: boolean) => {
13+
isInputModeGlobal = _isInputMode
1414
}
1515

1616
/**
@@ -23,6 +23,7 @@ export function useWithdraw() {
2323
useGenerateSapphireAccount()
2424
const [consensusAddress, setConsensusAddress] = useState<`oasis1${string}`>()
2525
const [progress, setProgress] = useState({ percentage: 0 as number | undefined, message: '' })
26+
const [_isInputMode, _setIsInputMode] = useState(true)
2627
const { refetch: updateBalanceInsideConnectButton, data: availableBalance } = useBalance({
2728
address: sapphireAddress,
2829
})
@@ -99,11 +100,16 @@ export function useWithdraw() {
99100
}
100101

101102
// Loop unless in input mode, case when user click transfer more
102-
if (!isInputMode) {
103+
if (!isInputModeGlobal) {
103104
await step4(consensusAddress)
104105
}
105106
}
106107

108+
function setIsInputMode(inputMode: boolean) {
109+
_setIsInputMode(inputMode)
110+
setIsInputModeGlobal(inputMode)
111+
}
112+
107113
function transferMore() {
108114
setIsInputMode(true)
109115
}
@@ -121,7 +127,7 @@ export function useWithdraw() {
121127
availableBalance,
122128
progress,
123129
isBlockingNavigatingAway,
124-
isInputMode,
130+
isInputMode: _isInputMode,
125131
setIsInputMode,
126132
isPrevError,
127133
}

ui/src/move/components/Input/index.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,9 @@ export const Input: FC<Props> = ({
2828
useLayoutEffect(() => {
2929
if (ref.current) {
3030
ref.current.value = initialValue ?? ''
31+
onChange?.(ref.current.value)
3132
}
33+
// eslint-disable-next-line react-hooks/exhaustive-deps
3234
}, [initialValue])
3335

3436
return (

0 commit comments

Comments
 (0)