From 0a3af4eb224d68cfe1b3e16b912549cb52e5d0a5 Mon Sep 17 00:00:00 2001 From: fragosti Date: Thu, 1 Nov 2018 13:37:43 -0700 Subject: chore: add clarification to _generateSelectAssetClickHandler --- .../src/components/erc20_asset_amount_input.tsx | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/packages/instant/src/components/erc20_asset_amount_input.tsx b/packages/instant/src/components/erc20_asset_amount_input.tsx index 05b81e93d..56f892328 100644 --- a/packages/instant/src/components/erc20_asset_amount_input.tsx +++ b/packages/instant/src/components/erc20_asset_amount_input.tsx @@ -122,18 +122,19 @@ export class ERC20AssetAmountInput extends React.Component void) | undefined => { - const { numberOfAssetsAvailable } = this.props; - if (_.isUndefined(numberOfAssetsAvailable) || numberOfAssetsAvailable <= 1) { + // We don't want to allow opening the token selection panel if there are no assets. + // Since styles are inferred from the presence of a click handler, we want to return undefined + // instead of providing a noop. + const { numberOfAssetsAvailable, onSelectAssetClick } = this.props; + if ( + _.isUndefined(numberOfAssetsAvailable) || + numberOfAssetsAvailable <= 1 || + _.isUndefined(onSelectAssetClick) + ) { return undefined; } - return this._handleSelectAssetClick; - }; - private readonly _handleSelectAssetClick = () => { - if (this.props.onSelectAssetClick) { - this.props.onSelectAssetClick(this.props.asset); - } + return () => onSelectAssetClick(this.props.asset); }; // For assets with symbols of different length, // start scaling the input at different character lengths -- cgit v1.2.3