-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Conversation
@@ -78,7 +78,7 @@ class InputAddress extends Component { | |||
return ( | |||
<div className={ containerClasses.join(' ') }> | |||
<Input | |||
allowCopy={ allowCopy && (disabled ? value : false) } | |||
allowCopy={ allowCopy && ((disabled || readOnly) ? value : false) } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
allowCopy && !disabled && !readOnly && value
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We want it to be false
if value
is falsy, because otherwise (if allowCopy
isn't a boolean) the copy button would show and copy the passed value (could be ''
)
this.setState({ isEth: true, ethValue: fromWei(this.props.value) }); | ||
const { isEth, value } = this.props; | ||
|
||
if (typeof isEth === 'boolean' && value) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess there is a specific reason for this, but isn't boolean validation done by propTypes
already?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It could be undefined
I think
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
undefined
is falsy.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So the logic is :
- If
isEth
is a prop (false
ortrue
), then theETH
toggle will be shown forinteger
inputs
The prop value will then be the default toggle state (ie.false
doesn't convert the value toETH
by default) - Else (ie.
undefined
, not aboolean
), don't show the toggle at all
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, then my only grumble is the tri-state isEth
(null
is the default value).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well it's more or less like allowCopy
: could be true or false whether to show it or not, or the value to actually copy. I agree that it might not be the best, but I'm not sure that it's in the scope of this PR.
label={ label } | ||
hint={ hint } | ||
value={ realValue } | ||
error={ error } | ||
onChange={ onChange } | ||
type='number' | ||
readOnly={ readOnly } | ||
type={ readOnly ? 'text' : 'number' } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Because if the TypedInput is read only and a number, we display the formatted number (which must be in a text input then)
const param = this.getParam(); | ||
|
||
const realValue = value && typeof value.toNumber === 'function' | ||
? value.toNumber() | ||
? (readOnly ? value.toFormat() : value.toNumber()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[tiny grumble] I'd rather check if it's a BigNumber
here, because you use both toFormat
& toNumber
.
label={ label } | ||
hint={ hint } | ||
value={ value } | ||
editing |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
afaict editing
does not exist as a prop.
} else if (api.util.isArray(value)) { | ||
} | ||
|
||
if (api.util.isArray(value)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
else
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Something is returned in the previous if
statement, thus no need for else
Closes #3918