diff --git a/src/components/search/Input.jsx b/src/components/search/Input.jsx index abb869b..cbdbaac 100644 --- a/src/components/search/Input.jsx +++ b/src/components/search/Input.jsx @@ -4,7 +4,7 @@ import querystring from 'querystring'; // import * as oMapper from 'object-mapper'; import { fetchJSON } from './../../utils/request'; import { observer } from 'mobx-react'; -import { merge, objectMapper } from './../../utils/commons'; +import { isEmpty, merge, objectMapper } from './../../utils/commons'; const { Option } = Select; @@ -24,7 +24,7 @@ function curl(opts, callback) { const _p = [{ 'key': '0', 'label': 'çİş' }]; return callback(_p); } - const param = merge({ code: 'utf-8', q: opts.value }, opts.param); + const param = merge({ code: 'utf-8', q: String(opts.value).trim() }, opts.param); // const str = new URLSearchParams({ // code: 'utf-8', // q: opts.value, @@ -91,7 +91,7 @@ class SearchInput extends React.Component { const { map, resultkey, dependenciesFun } = this.props; const param = typeof dependenciesFun === 'function' ? dependenciesFun() : {}; const mapKey = Object.keys(map).reduce((r, v) => ({ ...r, [v]: { key: map[v] } }), {}); - if (value) { + if (value || !isEmpty(param)) { curl({ value, url: this.props.url || '', map: mapKey, resultkey, param }, (data) => this.setState({ data }, () => (typeof this.props.onSearchAfter === 'function' ? this.props.onSearchAfter(data, this.state.value) : '')) ); @@ -120,6 +120,7 @@ class SearchInput extends React.Component { filterOption={false} onSearch={this.handleSearch} onChange={this.handleChange} + onFocus={() => this.handleSearch('')} notFoundContent={null} allowClear={true} onClear={this.handleClear}