From 49b3732774ce9df428327619da916975feb4defb Mon Sep 17 00:00:00 2001 From: Arthur Date: Tue, 21 Mar 2017 17:36:45 +0300 Subject: [PATCH] * #7. fix search with onKeyUp --- src/components/Header.js | 21 +++++++++++---------- src/components/Main.js | 14 ++++++++------ 2 files changed, 19 insertions(+), 16 deletions(-) diff --git a/src/components/Header.js b/src/components/Header.js index 4941015..326c3ab 100644 --- a/src/components/Header.js +++ b/src/components/Header.js @@ -28,16 +28,17 @@ class Header extends React.Component { if (columnsSearch[data] !== CommonConstants.UNDEFINED) { val = columnsSearch[data]; } - return ( -
- -
- ); + return ( +
+ +
+ ); } return
{children}
; } diff --git a/src/components/Main.js b/src/components/Main.js index 7936a8c..e10924b 100644 --- a/src/components/Main.js +++ b/src/components/Main.js @@ -58,9 +58,9 @@ 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({ + [name]: val + }); if (this.nothing === true && val === '') { return; // exit - user pressed not a symbol keys or teared down } @@ -96,9 +96,9 @@ class Main extends React.Component { this.c++; } this.nothing = false; - // this.setState({ - // dataSearch: nJson - // }); + this.setState({ + dataSearch: nJson + }); } this.lastTimeKeyup = this.nowMillis; } @@ -470,9 +470,11 @@ class Main extends React.Component { }) }); if (this.nothing === true && val === '') { + console.log('nothing'); return; // exit - user pressed not a symbol keys or teared down } if (this.nothing === false && val === '') { // rebuild full table if teared down + console.log('teared down'); this.createTable(this.jsonData, this.state.sortedButtons); this.nothing = true; return;