Skip to content

Commit

Permalink
fix(wallet-setup): mnemonic input (#3199)
Browse files Browse the repository at this point in the history
  • Loading branch information
banklesss committed Apr 16, 2024
1 parent 4683879 commit b421f82
Showing 1 changed file with 1 addition and 6 deletions.
Expand Up @@ -167,7 +167,6 @@ const MnemonicWordInput = React.forwardRef<RNTextInput, MnemonicWordInputProps>(
const dateTime = React.useRef<number>()
const [error, setError] = React.useState('')
const [matchingWords, setMatchingWords] = React.useState<Array<string>>([])
const [wordSubmitted, setWordSubmitted] = React.useState(false)

const selectWord = React.useCallback(
(matchingWord: string) => {
Expand All @@ -183,16 +182,13 @@ const MnemonicWordInput = React.forwardRef<RNTextInput, MnemonicWordInputProps>(
)

const onSubmitEditing = React.useCallback(() => {
setWordSubmitted(true)
if (!isEmptyString(matchingWords[0])) {
selectWord(matchingWords[0])
}
}, [matchingWords, selectWord])

const onChangeText = React.useCallback(
(text: string) => {
if (wordSubmitted) return // to fix ios simulator issue

if (text.endsWith(' ')) {
text = text.trimEnd()
setWord(normalizeText(text))
Expand All @@ -210,7 +206,7 @@ const MnemonicWordInput = React.forwardRef<RNTextInput, MnemonicWordInputProps>(
} else if (error !== '') setError('')
} else setMatchingWords([])
},
[error, onSubmitEditing, wordSubmitted],
[error, onSubmitEditing],
)

React.useEffect(() => {
Expand All @@ -236,7 +232,6 @@ const MnemonicWordInput = React.forwardRef<RNTextInput, MnemonicWordInputProps>(
})
}

setWordSubmitted(false)
onFocus()
}}
onChange={() => {
Expand Down

0 comments on commit b421f82

Please sign in to comment.