mirror of
https://github.com/kremalicious/metamask-extension.git
synced 2024-12-23 09:52:26 +01:00
Fixing leading zero when amount input is focused (#11459)
Fixes MetaMask/metamask-extension#11146
This commit is contained in:
parent
9e86d417f9
commit
a835f00ba6
@ -45,6 +45,18 @@ export default class UnitInput extends PureComponent {
|
||||
this.unitInput.focus();
|
||||
};
|
||||
|
||||
handleInputFocus = ({ target: { value } }) => {
|
||||
if (value === '0') {
|
||||
this.setState({ value: '' });
|
||||
}
|
||||
};
|
||||
|
||||
handleInputBlur = ({ target: { value } }) => {
|
||||
if (value === '') {
|
||||
this.setState({ value: '0' });
|
||||
}
|
||||
};
|
||||
|
||||
handleChange = (event) => {
|
||||
const { value: userInput } = event.target;
|
||||
let value = userInput;
|
||||
@ -88,6 +100,8 @@ export default class UnitInput extends PureComponent {
|
||||
value={value}
|
||||
placeholder={placeholder}
|
||||
onChange={this.handleChange}
|
||||
onBlur={this.handleInputBlur}
|
||||
onFocus={this.handleInputFocus}
|
||||
style={{ width: this.getInputWidth(value) }}
|
||||
ref={(ref) => {
|
||||
this.unitInput = ref;
|
||||
|
Loading…
Reference in New Issue
Block a user