import React, { PropTypes, PureComponent } from 'react';
import { findDOMNode } from 'react-dom';
import { InputGroup } from 'binary-components';
import { isMobile } from 'binary-utils';
import { actions } from '../_store';
import MarketSubmarketPickerContainer from './MarketSubmarketPickerContainer';

export default class AssetPickerFilter extends PureComponent {

	static propTypes = {
		filter: PropTypes.object.isRequired,
	};

	componentDidMount() {
		const assetSearchNode = findDOMNode(this);
		if (!isMobile()) {
			setTimeout(() => assetSearchNode.firstChild.focus(), 300);
		}
	}

	onSearchQueryChange = e => {
		actions.updateAssetPickerSearchQuery(e.target.value);
	}

	onFilterChange = e => {
		actions.updateAssetPickerFilter(e);
	}

	render() {
		const { filter } = this.props;

		return (
			<div className="asset-picker-filter">
				<InputGroup
					className="asset-search"
					defaultValue={filter.query}
					type="search"
					placeholder="Search for assets"
					onChange={this.onSearchQueryChange}
				/>
				<MarketSubmarketPickerContainer
					onChange={this.onFilterChange}
					allOptionShown
					value={filter.filter}
				/>
			</div>
		);
	}
}

import React, { PropTypes, PureComponent } from 'react';
import { findDOMNode } from 'react-dom';
import { InputGroup } from 'binary-components';
import { isMobile } from 'binary-utils';
import { actions } from '../_store';
import MarketSubmarketPickerContainer from './MarketSubmarketPickerContainer';

export default class AssetPickerFilter extends PureComponent {

	static propTypes = {
		filter: PropTypes.object.isRequired,
	};

	componentDidMount() {
		const assetSearchNode = findDOMNode(this);
		if (!isMobile()) {
			setTimeout(() =>
				assetSearchNode.firstChild &&
				assetSearchNode.firstChild.firstChild &&
				assetSearchNode.firstChild.firstChild.focus(),
			100);
		}
	}

	onSearchQueryChange = e => {
		actions.updateAssetPickerSearchQuery(e.target.value);
	}

	onFilterChange = e => {
		actions.updateAssetPickerFilter(e);
	}

	render() {
		const { filter } = this.props;

		return (
			<div className="asset-picker-filter">
				<InputGroup
					className="asset-search"
					defaultValue={filter.query}
					type="search"
					placeholder="Search for assets"
					onChange={this.onSearchQueryChange}
				/>
				<MarketSubmarketPickerContainer
					onChange={this.onFilterChange}
					allOptionShown
					value={filter.filter}
				/>
			</div>
		);
	}
}

Fix asset picker input focus
Fix asset picker input focus
