mirror of
https://github.com/kremalicious/metamask-extension.git
synced 2024-12-23 09:52:26 +01:00
Allow editing transaction amount after clicking max (#10278)
This commit is contained in:
parent
d0df03b89a
commit
569672027c
@ -308,8 +308,6 @@ describe('MetaMask', function () {
|
|||||||
)
|
)
|
||||||
await amountMax.click()
|
await amountMax.click()
|
||||||
|
|
||||||
assert.equal(await inputAmount.isEnabled(), false)
|
|
||||||
|
|
||||||
let inputValue = await inputAmount.getAttribute('value')
|
let inputValue = await inputAmount.getAttribute('value')
|
||||||
|
|
||||||
assert(Number(inputValue) > 99)
|
assert(Number(inputValue) > 99)
|
||||||
|
@ -21,7 +21,6 @@ export default class CurrencyInput extends PureComponent {
|
|||||||
static propTypes = {
|
static propTypes = {
|
||||||
conversionRate: PropTypes.number,
|
conversionRate: PropTypes.number,
|
||||||
currentCurrency: PropTypes.string,
|
currentCurrency: PropTypes.string,
|
||||||
maxModeOn: PropTypes.bool,
|
|
||||||
nativeCurrency: PropTypes.string,
|
nativeCurrency: PropTypes.string,
|
||||||
onChange: PropTypes.func,
|
onChange: PropTypes.func,
|
||||||
useFiat: PropTypes.bool,
|
useFiat: PropTypes.bool,
|
||||||
@ -153,7 +152,7 @@ export default class CurrencyInput extends PureComponent {
|
|||||||
}
|
}
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
const { fiatSuffix, nativeSuffix, maxModeOn, ...restProps } = this.props
|
const { fiatSuffix, nativeSuffix, ...restProps } = this.props
|
||||||
const { decimalValue } = this.state
|
const { decimalValue } = this.state
|
||||||
|
|
||||||
return (
|
return (
|
||||||
@ -162,7 +161,6 @@ export default class CurrencyInput extends PureComponent {
|
|||||||
suffix={this.shouldUseFiat() ? fiatSuffix : nativeSuffix}
|
suffix={this.shouldUseFiat() ? fiatSuffix : nativeSuffix}
|
||||||
onChange={this.handleChange}
|
onChange={this.handleChange}
|
||||||
value={decimalValue}
|
value={decimalValue}
|
||||||
maxModeOn={maxModeOn}
|
|
||||||
actionComponent={
|
actionComponent={
|
||||||
<div className="currency-input__swap-component" onClick={this.swap} />
|
<div className="currency-input__swap-component" onClick={this.swap} />
|
||||||
}
|
}
|
||||||
|
@ -1,10 +1,6 @@
|
|||||||
import { connect } from 'react-redux'
|
import { connect } from 'react-redux'
|
||||||
import { ETH } from '../../../helpers/constants/common'
|
import { ETH } from '../../../helpers/constants/common'
|
||||||
import {
|
import { getIsMainnet, getPreferences } from '../../../selectors'
|
||||||
getSendMaxModeState,
|
|
||||||
getIsMainnet,
|
|
||||||
getPreferences,
|
|
||||||
} from '../../../selectors'
|
|
||||||
import CurrencyInput from './currency-input.component'
|
import CurrencyInput from './currency-input.component'
|
||||||
|
|
||||||
const mapStateToProps = (state) => {
|
const mapStateToProps = (state) => {
|
||||||
@ -13,14 +9,12 @@ const mapStateToProps = (state) => {
|
|||||||
} = state
|
} = state
|
||||||
const { showFiatInTestnets } = getPreferences(state)
|
const { showFiatInTestnets } = getPreferences(state)
|
||||||
const isMainnet = getIsMainnet(state)
|
const isMainnet = getIsMainnet(state)
|
||||||
const maxModeOn = getSendMaxModeState(state)
|
|
||||||
|
|
||||||
return {
|
return {
|
||||||
nativeCurrency,
|
nativeCurrency,
|
||||||
currentCurrency,
|
currentCurrency,
|
||||||
conversionRate,
|
conversionRate,
|
||||||
hideFiat: !isMainnet && !showFiatInTestnets,
|
hideFiat: !isMainnet && !showFiatInTestnets,
|
||||||
maxModeOn,
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -30,9 +30,6 @@ describe('CurrencyInput container', function () {
|
|||||||
provider: {
|
provider: {
|
||||||
type: 'mainnet',
|
type: 'mainnet',
|
||||||
},
|
},
|
||||||
send: {
|
|
||||||
maxModeOn: false,
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
expected: {
|
expected: {
|
||||||
@ -40,7 +37,6 @@ describe('CurrencyInput container', function () {
|
|||||||
currentCurrency: 'usd',
|
currentCurrency: 'usd',
|
||||||
nativeCurrency: 'ETH',
|
nativeCurrency: 'ETH',
|
||||||
hideFiat: false,
|
hideFiat: false,
|
||||||
maxModeOn: false,
|
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
// Test # 2
|
// Test # 2
|
||||||
@ -58,9 +54,6 @@ describe('CurrencyInput container', function () {
|
|||||||
provider: {
|
provider: {
|
||||||
type: 'rinkeby',
|
type: 'rinkeby',
|
||||||
},
|
},
|
||||||
send: {
|
|
||||||
maxModeOn: false,
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
expected: {
|
expected: {
|
||||||
@ -68,7 +61,6 @@ describe('CurrencyInput container', function () {
|
|||||||
currentCurrency: 'usd',
|
currentCurrency: 'usd',
|
||||||
nativeCurrency: 'ETH',
|
nativeCurrency: 'ETH',
|
||||||
hideFiat: true,
|
hideFiat: true,
|
||||||
maxModeOn: false,
|
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
// Test # 3
|
// Test # 3
|
||||||
@ -86,9 +78,6 @@ describe('CurrencyInput container', function () {
|
|||||||
provider: {
|
provider: {
|
||||||
type: 'rinkeby',
|
type: 'rinkeby',
|
||||||
},
|
},
|
||||||
send: {
|
|
||||||
maxModeOn: false,
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
expected: {
|
expected: {
|
||||||
@ -96,7 +85,6 @@ describe('CurrencyInput container', function () {
|
|||||||
currentCurrency: 'usd',
|
currentCurrency: 'usd',
|
||||||
nativeCurrency: 'ETH',
|
nativeCurrency: 'ETH',
|
||||||
hideFiat: false,
|
hideFiat: false,
|
||||||
maxModeOn: false,
|
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
// Test # 4
|
// Test # 4
|
||||||
@ -114,9 +102,6 @@ describe('CurrencyInput container', function () {
|
|||||||
provider: {
|
provider: {
|
||||||
type: 'mainnet',
|
type: 'mainnet',
|
||||||
},
|
},
|
||||||
send: {
|
|
||||||
maxModeOn: false,
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
expected: {
|
expected: {
|
||||||
@ -124,7 +109,6 @@ describe('CurrencyInput container', function () {
|
|||||||
currentCurrency: 'usd',
|
currentCurrency: 'usd',
|
||||||
nativeCurrency: 'ETH',
|
nativeCurrency: 'ETH',
|
||||||
hideFiat: false,
|
hideFiat: false,
|
||||||
maxModeOn: false,
|
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
]
|
]
|
||||||
|
@ -13,7 +13,6 @@ export default class UnitInput extends PureComponent {
|
|||||||
children: PropTypes.node,
|
children: PropTypes.node,
|
||||||
actionComponent: PropTypes.node,
|
actionComponent: PropTypes.node,
|
||||||
error: PropTypes.bool,
|
error: PropTypes.bool,
|
||||||
maxModeOn: PropTypes.bool,
|
|
||||||
onChange: PropTypes.func,
|
onChange: PropTypes.func,
|
||||||
placeholder: PropTypes.string,
|
placeholder: PropTypes.string,
|
||||||
suffix: PropTypes.string,
|
suffix: PropTypes.string,
|
||||||
@ -63,33 +62,20 @@ export default class UnitInput extends PureComponent {
|
|||||||
}
|
}
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
const {
|
const { error, placeholder, suffix, actionComponent, children } = this.props
|
||||||
error,
|
|
||||||
placeholder,
|
|
||||||
suffix,
|
|
||||||
actionComponent,
|
|
||||||
children,
|
|
||||||
maxModeOn,
|
|
||||||
} = this.props
|
|
||||||
const { value } = this.state
|
const { value } = this.state
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div
|
<div
|
||||||
className={classnames(
|
className={classnames('unit-input', { 'unit-input--error': error })}
|
||||||
'unit-input',
|
onClick={this.handleFocus}
|
||||||
{ 'unit-input--error': error },
|
|
||||||
{ 'unit-input__disabled': maxModeOn },
|
|
||||||
)}
|
|
||||||
onClick={maxModeOn ? null : this.handleFocus}
|
|
||||||
>
|
>
|
||||||
<div className="unit-input__inputs">
|
<div className="unit-input__inputs">
|
||||||
<div className="unit-input__input-container">
|
<div className="unit-input__input-container">
|
||||||
<input
|
<input
|
||||||
type="number"
|
type="number"
|
||||||
dir="ltr"
|
dir="ltr"
|
||||||
className={classnames('unit-input__input', {
|
className={classnames('unit-input__input')}
|
||||||
'unit-input__disabled': maxModeOn,
|
|
||||||
})}
|
|
||||||
value={value}
|
value={value}
|
||||||
placeholder={placeholder}
|
placeholder={placeholder}
|
||||||
onChange={this.handleChange}
|
onChange={this.handleChange}
|
||||||
@ -97,7 +83,6 @@ export default class UnitInput extends PureComponent {
|
|||||||
ref={(ref) => {
|
ref={(ref) => {
|
||||||
this.unitInput = ref
|
this.unitInput = ref
|
||||||
}}
|
}}
|
||||||
disabled={maxModeOn}
|
|
||||||
/>
|
/>
|
||||||
{suffix && <div className="unit-input__suffix">{suffix}</div>}
|
{suffix && <div className="unit-input__suffix">{suffix}</div>}
|
||||||
</div>
|
</div>
|
||||||
|
Loading…
Reference in New Issue
Block a user