From 26f68203510dc261866cea9c230d408dc48c29b1 Mon Sep 17 00:00:00 2001 From: Zhiting Lin Date: Mon, 21 May 2018 11:09:26 +0800 Subject: [PATCH] submit the form when user hit enter --- .../transactions/components/New/AdvancedTransactionForm.jsx | 3 ++- src/features/transactions/components/New/New.jsx | 9 +++++++++ .../transactions/components/New/NormalTransactionForm.jsx | 4 +++- 3 files changed, 14 insertions(+), 2 deletions(-) diff --git a/src/features/transactions/components/New/AdvancedTransactionForm.jsx b/src/features/transactions/components/New/AdvancedTransactionForm.jsx index 523010b..b55c399 100644 --- a/src/features/transactions/components/New/AdvancedTransactionForm.jsx +++ b/src/features/transactions/components/New/AdvancedTransactionForm.jsx @@ -88,7 +88,8 @@ class AdvancedTxForm extends React.Component { } return ( -
+ { this.props.handleKeyDown(e, handleSubmit(this.submitWithValidation), this.disableSubmit(actions)) }}> {actions.map((action, index) => diff --git a/src/features/transactions/components/New/New.jsx b/src/features/transactions/components/New/New.jsx index 092fa7a..a12b409 100644 --- a/src/features/transactions/components/New/New.jsx +++ b/src/features/transactions/components/New/New.jsx @@ -48,6 +48,13 @@ class Form extends React.Component { } } + handleKeyDown(e, cb, disable) { + if (e.key === 'Enter' && e.shiftKey === false && !disable) { + e.preventDefault() + cb() + } + } + render() { const lang = this.props.lang @@ -126,6 +133,7 @@ class Form extends React.Component { btmAmountUnit={this.props.btmAmountUnit} balanceAmount={balanceAmount} assetDecimal={assetDecimal} + handleKeyDown={this.handleKeyDown} /> } {this.state.showAdvanceTx && @@ -135,6 +143,7 @@ class Form extends React.Component { asset={this.props.asset} balanceAmount={balanceAmount} assetDecimal={assetDecimal} + handleKeyDown={this.handleKeyDown} />} diff --git a/src/features/transactions/components/New/NormalTransactionForm.jsx b/src/features/transactions/components/New/NormalTransactionForm.jsx index e971b5c..43d7dd5 100644 --- a/src/features/transactions/components/New/NormalTransactionForm.jsx +++ b/src/features/transactions/components/New/NormalTransactionForm.jsx @@ -179,7 +179,9 @@ class NormalTxForm extends React.Component { const showBtmAmountUnit = (assetAlias.value === 'BTM' || assetId.value === btmID) return ( - + { this.props.handleKeyDown(e, handleSubmit(this.submitWithValidation), this.disableSubmit(this.props.fields)) }}>
-- 2.11.0