Skip to content

Commit 592057b

Browse files
committed
fix: cursor move to last position
1 parent 0a2deb6 commit 592057b

File tree

1 file changed

+13
-2
lines changed
  • packages/neuron-ui/src/components/DepositDialog

1 file changed

+13
-2
lines changed

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

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import React, { useCallback, useMemo } from 'react'
1+
import React, { useCallback, useMemo, useState } from 'react'
22
import { Slider } from 'office-ui-fabric-react'
33
import { Trans, useTranslation } from 'react-i18next'
44
import TextField from 'widgets/TextField'
@@ -66,6 +66,7 @@ const DepositDialog = ({
6666
}: DepositDialogProps) => {
6767
const [t, { language }] = useTranslation()
6868
const disabled = !isTxGenerated
69+
const [isTyping, setIsTyping] = useState(false)
6970
const { isBalanceReserved, onIsBalanceReservedChange, setIsBalanceReserved } = useBalanceReserved()
7071
const { depositValue, onChangeDepositValue, slidePercent, onSliderChange, resetDepositValue } = useDepositValue(
7172
balance,
@@ -108,6 +109,14 @@ const DepositDialog = ({
108109

109110
const isChinese = language === 'zh' || language.startsWith('zh-')
110111

112+
const handleBlur = useCallback(() => {
113+
setIsTyping(false)
114+
}, [setIsTyping])
115+
116+
const handleFocus = useCallback(() => {
117+
setIsTyping(true)
118+
}, [setIsTyping])
119+
111120
return (
112121
<Dialog
113122
show={show}
@@ -151,8 +160,10 @@ const DepositDialog = ({
151160
className={styles.depositValue}
152161
width="100%"
153162
field="depositValue"
154-
value={localNumberFormatter(maxDepositValue ?? depositValue)}
163+
value={isTyping ? maxDepositValue ?? depositValue : localNumberFormatter(maxDepositValue ?? depositValue)}
155164
onChange={onChangeDepositValue}
165+
onBlur={handleBlur}
166+
onFocus={handleFocus}
156167
suffix="CKB"
157168
required
158169
error={errorMessage}

0 commit comments

Comments
 (0)