Skip to content

Commit

Permalink
Fix: Inputs malfunction (#791)
Browse files Browse the repository at this point in the history
* fix: DomainInput

* fix: ImportNewMasterKey inputs
  • Loading branch information
TravellerOnTheRun authored Oct 31, 2023
1 parent 9b4eea8 commit e3b5881
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 7 deletions.
6 changes: 4 additions & 2 deletions src/screens/createKeys/import/ImportMasterKeyScreen.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ export const ImportMasterKeyScreen = (
const { t } = useTranslation()

const dispatch = useAppDispatch()
const words = useRef<string[]>([...initialWords])
const words = useRef<string[]>(initialWords)
const inputsRef = useRef<Record<string, TextInput>>({})
const carouselRef = useRef<ICarouselInstance>(null)

Expand All @@ -60,6 +60,7 @@ export const ImportMasterKeyScreen = (
...words.current,
},
})
const { setValue } = form
const [selectedSlide, setSelectedSlide] = useState<number>(0)
const [status, setStatus] = useState<StatusActions>(StatusActions.INITIAL)

Expand Down Expand Up @@ -110,6 +111,7 @@ export const ImportMasterKeyScreen = (

const onChangeText = (index: number) => (value: string) => {
words.current[index - 1] = value.trim()
setValue(index.toString() as `${number}`, value.trim())
}

const onSetRef = (index: number) => (ref: TextInput) => {
Expand Down Expand Up @@ -170,7 +172,7 @@ export const ImportMasterKeyScreen = (
</View>
)
},
[handleImportMnemonic, onSubmitEditing],
[handleImportMnemonic, onSubmitEditing, setValue],
)

return (
Expand Down
11 changes: 6 additions & 5 deletions src/screens/rnsManager/DomainInput.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import { minDomainLength } from './SearchDomainScreen'
interface Props {
wallet: RIFWallet
inputName: string
domainValue: string
error: FieldError | undefined
onDomainAvailable: (domain: string, valid: boolean) => void
onDomainOwned: (owned: boolean) => void
Expand All @@ -48,12 +49,12 @@ const labelColorMap = new Map([
export const DomainInput = ({
wallet,
inputName,
domainValue,
onDomainAvailable,
onDomainOwned,
onResetValue,
error,
}: Props) => {
const [username, setUsername] = useState<string>('')
const [domainAvailability, setDomainAvailability] = useState<DomainStatus>(
DomainStatus.NONE,
)
Expand Down Expand Up @@ -141,12 +142,13 @@ export const DomainInput = ({
setDomainAvailability(DomainStatus.NONE)
onDomainAvailable('', false)
onDomainOwned(false)
setUsername('')
}

useEffect(() => {
handleChangeUsername(username)
}, [error, username, handleChangeUsername])
if (domainValue !== undefined) {
handleChangeUsername(domainValue)
}
}, [error, domainValue, handleChangeUsername])

const labelTextMap = new Map([
[DomainStatus.AVAILABLE, t('username_available')],
Expand All @@ -171,7 +173,6 @@ export const DomainInput = ({
labelStyle={labelStyle}
placeholderStyle={styles.domainPlaceholder}
resetValue={resetField}
onChangeText={setUsername}
suffix={<Text style={styles.domainSuffix}>.rsk</Text>}
autoCapitalize="none"
autoCorrect={false}
Expand Down
1 change: 1 addition & 0 deletions src/screens/rnsManager/SearchDomainScreen.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -238,6 +238,7 @@ export const SearchDomainScreen = ({ navigation }: Props) => {
wallet={wallet}
inputName={'domain'}
error={errors.domain}
domainValue={domain}
onDomainOwned={setIsDomainOwned}
onDomainAvailable={handleDomainAvailable}
onResetValue={() => {
Expand Down

0 comments on commit e3b5881

Please sign in to comment.