Skip to content

Commit

Permalink
* #7. fix search filling with Worning
Browse files Browse the repository at this point in the history
  • Loading branch information
arthurkushman committed Mar 21, 2017
1 parent 80c3dc8 commit 8399dd0
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 5 deletions.
15 changes: 12 additions & 3 deletions src/components/Header.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,23 @@ class Header extends React.Component {
columns,
data,
sortId,
doDiscreteSearch
doDiscreteSearch,
columnsSearch
} = this.props;

if (this.isDiscreteSearch === true) {
let val = '';
if (columnsSearch[data] !== CommonConstants.UNDEFINED) {
val = columnsSearch[data];
}
return (
<div className={styles.gt_th_box}>
<input data-index={data} name={data} onChange={doDiscreteSearch}
placeholder={columns[sortId].discreteSearchValue(data)} />
<input
data-index={data}
name={data}
onChange={doDiscreteSearch}
placeholder={columns[sortId].discreteSearchValue(data)}
value={val} />
</div>
);
}
Expand Down
7 changes: 5 additions & 2 deletions src/components/Main.js
Original file line number Diff line number Diff line change
Expand Up @@ -464,8 +464,10 @@ class Main extends React.Component {
var period = this.nowMillis - this.lastTimeKeyup;

if (len > 0 || (len === 0 && val === '')) { // do search
this.setState({
[name]: val
this.setState({columnsSearch:
Object.assign({}, this.state.columnsSearch, {
[name]: val
})
});
if (this.nothing === true && val === '') {
return; // exit - user pressed not a symbol keys or teared down
Expand Down Expand Up @@ -528,6 +530,7 @@ class Main extends React.Component {
};
clonedOpts['columns'] = columns;
clonedOpts['doDiscreteSearch'] = this.doDiscreteSearch.bind(this);
clonedOpts['columnsSearch'] = this.state.columnsSearch;
if (this.sortableCols[data] === true) {
clonedOpts['gteSort'] = CommonConstants.SORTABLE;
if(typeof sortButtons[data] !== CommonConstants.UNDEFINED) {
Expand Down

0 comments on commit 8399dd0

Please sign in to comment.