From 0bd7188d968fae4c15dea6f15272ef70bc8d9878 Mon Sep 17 00:00:00 2001 From: Jungo Kim Date: Tue, 3 May 2016 11:18:33 +0900 Subject: [PATCH 1/3] [client] master tab : fix minor bug regarding tab change Modify marginTop value for login buttonwq --- client/src/app/components/login-select.jsx | 2 +- client/src/app/components/master.jsx | 14 +++++++++++++- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/client/src/app/components/login-select.jsx b/client/src/app/components/login-select.jsx index 9d3ea4f..68c513e 100644 --- a/client/src/app/components/login-select.jsx +++ b/client/src/app/components/login-select.jsx @@ -26,7 +26,7 @@ var LoginSel = React.createClass({ width: '100%', height: '45px', float: 'left', - marginTop: '5px', + marginTop: '10px', }, kakaoText: { color: "#3c1e1e", diff --git a/client/src/app/components/master.jsx b/client/src/app/components/master.jsx index a60eadf..7dd8cce 100644 --- a/client/src/app/components/master.jsx +++ b/client/src/app/components/master.jsx @@ -117,11 +117,16 @@ var Master = React.createClass({ }.bind(this); setTabsState(); window.onresize = setTabsState; + this.lastTabIndex = '1'; }, componentWillReceiveProps: function() { console.log("master componentWillReceiveProps"); - this.setState({tabIndex: this._getSelectedIndex()}); + if (!this.context.router.isActive('new-asks')) { + this.setState({tabIndex: '0'}); + } else { + this.setState({tabIndex: this.lastTabIndex}); + } }, _getSelectedIndex: function() { @@ -129,7 +134,14 @@ var Master = React.createClass({ }, _handleTabChange: function(value, e, tab) { + console.log("master _handleTabChange"); + if (!this.context.router.isActive('new-asks')) { + this.context.router.transitionTo('new-asks'); + } + this.setState({tabIndex: value}); + this.lastTabIndex = value; + var event = new CustomEvent("tabChanged", { detail: { value: value From 9883537e228a6ee1ddbc45a3f8e04b0626c9057c Mon Sep 17 00:00:00 2001 From: Jungo Kim Date: Tue, 3 May 2016 13:18:37 +0900 Subject: [PATCH 2/3] [client] tab : remove custom tab change event Sync tabIndex between master and new ask by using window.tabIndex instead of this.tabIndex --- client/src/app/components/master.jsx | 15 ++++----------- client/src/app/components/new-asks.jsx | 13 +++---------- 2 files changed, 7 insertions(+), 21 deletions(-) diff --git a/client/src/app/components/master.jsx b/client/src/app/components/master.jsx index 7dd8cce..ab524f9 100644 --- a/client/src/app/components/master.jsx +++ b/client/src/app/components/master.jsx @@ -117,7 +117,7 @@ var Master = React.createClass({ }.bind(this); setTabsState(); window.onresize = setTabsState; - this.lastTabIndex = '1'; + window.lastTabIndex = '1'; }, componentWillReceiveProps: function() { @@ -125,7 +125,7 @@ var Master = React.createClass({ if (!this.context.router.isActive('new-asks')) { this.setState({tabIndex: '0'}); } else { - this.setState({tabIndex: this.lastTabIndex}); + this.setState({tabIndex: window.lastTabIndex}); } }, @@ -134,20 +134,13 @@ var Master = React.createClass({ }, _handleTabChange: function(value, e, tab) { - console.log("master _handleTabChange"); + console.log("master _handleTabChange value : " + value); if (!this.context.router.isActive('new-asks')) { this.context.router.transitionTo('new-asks'); } this.setState({tabIndex: value}); - this.lastTabIndex = value; - - var event = new CustomEvent("tabChanged", { - detail: { - value: value - } - }); - document.dispatchEvent(event); + window.lastTabIndex = value; window.scrollTo(0,0); }, diff --git a/client/src/app/components/new-asks.jsx b/client/src/app/components/new-asks.jsx index f51c736..0e09c46 100644 --- a/client/src/app/components/new-asks.jsx +++ b/client/src/app/components/new-asks.jsx @@ -18,7 +18,6 @@ var NewAsks = React.createClass({ componentWillMount: function () { console.log('New asks componentWillMount called'); console.log('window.newAsksState is ', window.newAsksState); - this.tabIndex = '1'; if (window.newAsksState === undefined || window.newAsksState === "UpdateNeeded") { var query = {}; @@ -74,11 +73,6 @@ var NewAsks = React.createClass({ componentDidMount: function () { console.log('New asks componentDidMount called'); console.log('window.newAsksState is ', window.newAsksState); - document.addEventListener("tabChanged", - function statusChangeCallback(e) { - this.tabIndex = e.detail.value; - }.bind(this) - ); }, componentWillUpdate: function(nextProps, nextState) { @@ -154,7 +148,6 @@ var NewAsks = React.createClass({ }.bind(this), 1000); } setTimeout( function() { - console.log("jungo"); this.refs.newAsksMoreButton.showButton(); }.bind(this), 1000); }.bind(this), @@ -166,7 +159,7 @@ var NewAsks = React.createClass({ }, render: function() { - console.log("new Asks rendering : " + this.tabIndex); + console.log("New Asks rendering : " + window.lastTabIndex); var root = { backgroundColor : Colors.grey100, }; @@ -179,7 +172,7 @@ var NewAsks = React.createClass({ backgroundColor : Colors.grey100, }; - var newTabStyle = this.tabIndex === "1" ? + var newTabStyle = window.lastTabIndex === "1" ? { position: "absolute", top: document.body.clientWidth <= 647 ? Spacing.desktopKeylineIncrement+48: Spacing.desktopKeylineIncrement, @@ -195,7 +188,7 @@ var NewAsks = React.createClass({ maxWidth : 650, }; - var hotTabStyle = this.tabIndex === "2" ? + var hotTabStyle = window.lastTabIndex === "2" ? { position: "absolute", top: document.body.clientWidth <= 647 ? Spacing.desktopKeylineIncrement+48: Spacing.desktopKeylineIncrement, From 72a06083760d131bbf29b65fc1efaa05cc4164fe Mon Sep 17 00:00:00 2001 From: Jungo Kim Date: Tue, 3 May 2016 13:31:12 +0900 Subject: [PATCH 3/3] [client] hot asks : fix bug of wrong list num after route transition --- client/src/app/components/new-asks.jsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/client/src/app/components/new-asks.jsx b/client/src/app/components/new-asks.jsx index 0e09c46..8436ed5 100644 --- a/client/src/app/components/new-asks.jsx +++ b/client/src/app/components/new-asks.jsx @@ -66,7 +66,7 @@ var NewAsks = React.createClass({ }); window.hotAsksState = "Updated"; } else if (window.hotAsksState === "Updated"){ - this.setState({hotAsksData: hotAsks}); + this.setState({hotAsksData: hotAsks.slice(0, 5)}); } },