From 498e8366b9e573eaa1a3f2312920cb0bcf85bd5e Mon Sep 17 00:00:00 2001 From: Artsiom Dziaryba Date: Wed, 13 Nov 2019 11:39:53 +0300 Subject: [PATCH] [BLP-467] fix: disable fee dropdown for freeze (#54) --- app/components/frozen-funds/form.jsx | 1 + app/components/input-dropdown/index.jsx | 153 +++++++++++++----------- 2 files changed, 82 insertions(+), 72 deletions(-) diff --git a/app/components/frozen-funds/form.jsx b/app/components/frozen-funds/form.jsx index 8eee4a5..e3f88db 100644 --- a/app/components/frozen-funds/form.jsx +++ b/app/components/frozen-funds/form.jsx @@ -314,6 +314,7 @@ class FrozenFundsForm extends React.Component { value={form.get('fee').value} setFee={this.props.setFeeFormValue} placeholder={placeholderFee} + isFreeze /> diff --git a/app/components/input-dropdown/index.jsx b/app/components/input-dropdown/index.jsx index 1b24d0c..34bb690 100644 --- a/app/components/input-dropdown/index.jsx +++ b/app/components/input-dropdown/index.jsx @@ -304,7 +304,7 @@ class InputDropdown extends React.Component { opened, focus, assetsList, tokensList, search, currentVal, } = this.state; const { - title, hints, disable, errorText, value: inputValue, name, intl, placeholder, + title, hints, disable, errorText, value: inputValue, name, intl, placeholder, isFreeze, } = this.props; const assetsTitle = intl.formatMessage({ id: 'send.dropdown.assets' }); @@ -352,86 +352,93 @@ class InputDropdown extends React.Component { name={name} value={inputValue} error={!!errorText} - disabled={disable} + disabled={disable || isFreeze} ref={(amountInput) => { this.amountInput = amountInput; }} className={classnames('field input-dropdown', { focus }, { disabled: isDropdownActive })} placeholder={title} - onFocus={() => this.setFocus(true)} - onBlur={() => this.setFocus(false)} + onFocus={isFreeze ? () => this.setFocus(true) : () => {}} + onBlur={isFreeze ? () => this.setFocus(false) : () => {}} onChange={(e) => this.props.onChange(e)} onKeyPress={(e) => this.props.onKeyPress(e)} action={(
- this.setFocus(true) : () => {}} - onBlur={() => this.setFocus(false)} - show={opened && isDropdownActive} - > - this.toggleDropdown() : () => {}} - variant="Info" - > + {isFreeze ? ( + {currentVal || 'ECHO'} - {isDropdownActive ? : null} - - - - - { e.stopPropagation(); e.preventDefault(); }} - onKeyDown={(e) => { this.onInputKeyDown(e); }} - onChange={(e) => this.onChange(e)} - ref={(node) => { this.searchInput = node; }} - /> - - { - isResultsExists - ? dropdownData.map((elem, index) => ( - elem.list.length - ? ( - -
-
{elem.title}
- { - elem.list.map(({ text, value, active }, i) => ( - - { - if (ref) { - if (!this.refList[index]) { - this.refList[index] = []; + + ) + : ( + this.setFocus(true) : () => {}} + onBlur={() => this.setFocus(false)} + show={opened && isDropdownActive} + > + this.toggleDropdown() : () => {}} + variant="Info" + > + {currentVal || 'ECHO'} + {isDropdownActive ? : null} + + + + + { e.stopPropagation(); e.preventDefault(); }} + onKeyDown={(e) => { this.onInputKeyDown(e); }} + onChange={(e) => this.onChange(e)} + ref={(node) => { this.searchInput = node; }} + /> + + { + isResultsExists + ? dropdownData.map((elem, index) => ( + elem.list.length + ? ( + + - ) : '' - )) :
No results
- } - - - + onKeyDown={(e) => this.onKeyDown(e, index, i)} + onClick={(e) => { + this.handleClick(e, text, value); + }} + > {text} + + )) + } +
+ ) : '' + )) :
No results
+ } +
+
+
+ )}
)} /> @@ -476,6 +483,7 @@ InputDropdown.propTypes = { onKeyPress: PropTypes.func, setFee: PropTypes.func, intl: intlShape.isRequired, + isFreeze: PropTypes.bool, }; InputDropdown.defaultProps = { @@ -492,6 +500,7 @@ InputDropdown.defaultProps = { onKeyPress: () => {}, setFee: () => {}, data: null, + isFreeze: false, }; export default injectIntl(InputDropdown);