Small tweaks to hash input (#9)

This commit is contained in:
Jaco Greeff 2018-04-30 08:50:52 +02:00 committed by GitHub
parent f60f4ede89
commit a514337b9b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 10 additions and 3 deletions

View File

@ -14,7 +14,13 @@ import Base from './Base';
export default function Hash ({ isError, label, subject, t }: Props): React$Node {
// eslint-disable-next-line no-unused-vars
const onChange = (event: SyntheticEvent<*>, { value }) => {
const u8a = hexToU8a(value);
let u8a;
try {
u8a = hexToU8a(value);
} catch (error) {
u8a = new Uint8Array([]);
}
subject.next({
isValid: u8a.length === 32,
@ -25,11 +31,12 @@ export default function Hash ({ isError, label, subject, t }: Props): React$Node
return (
<Base
label={label}
size='small'
size='medium'
>
<Input
error={isError}
onChange={onChange}
placeholder='0x...'
type='text'
/>
</Base>

View File

@ -30,7 +30,7 @@ export default function VoteThreshold ({ label, subject, t, value: { options: {
>
<Dropdown
selection
defaultValue={initValue}
defaultValue={initValue || 0}
options={options}
onChange={onChange}
/>