Skip to content

Commit 20350f9

Browse files
neyser zananeyser zana
authored andcommitted
fixes tree rendering bug
1 parent 8687a5b commit 20350f9

File tree

3 files changed

+21
-17
lines changed

3 files changed

+21
-17
lines changed

build/webpack-bundle.js

Lines changed: 6 additions & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

build/webpack-bundle.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/devtools.js

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -111,22 +111,26 @@ class App extends Component {
111111

112112
//* invoke schema fetch only after a log object from a previous response is available
113113
componentDidUpdate(prevProps, prevState) {
114+
console.log('LENGTH: ', this.state.appFilteredDOM.length)
114115
if (this.state.schema === "GraphQL schema not available.") {
115116
this.fetchSchemaFromGraphQLServer();
116117
}
117-
if (prevState.appReactDOM !== this.state.appReactDOM) {
118+
119+
if (prevState.appState !== this.state.appState) {
120+
console.log(this.state.componentsToFilter);
118121
if (this.state.componentsToFilter.length) {
119122
let result = [];
120-
filter(this.state.appReactDOM, this.state.componentsToFilter, result);
121-
this.setState({appFilteredDOM: result});
123+
filter(this.state.appState, this.state.componentsToFilter, result);
124+
this.setState({ appFilteredDOM: result });
122125
}
123126
}
124127
}
125128

126129

127130
// * Handles the tab click for tree and req/res window
128-
handleWindowChange() {
129-
if (this.state.window === 'Graphql') {
131+
handleWindowChange(target) {
132+
console.log(target);
133+
if (this.state.window === 'Graphql' && target.dataset.btn === 'React') {
130134
this.setState({ window: 'React' });
131135
document.querySelector('#reactbtn').classList.remove('active');
132136
document.querySelector('#graphqlbtn').classList.add('active');
@@ -142,7 +146,7 @@ class App extends Component {
142146
let result = [];
143147
if (!this.state.componentsToFilter.includes(arr[0])) {
144148
let componentsArr = this.state.componentsToFilter.concat(arr);
145-
filter(this.state.appReactDOM, this.state.componentsToFilter, result);
149+
filter(this.state.appState, componentsArr, result);
146150
this.setState({
147151
componentsToFilter: componentsArr,
148152
appFilteredDOM: result
@@ -154,7 +158,7 @@ class App extends Component {
154158
list.splice(i--, 1);
155159
}
156160
}
157-
filter(this.state.appReactDOM, this.state.componentsToFilter, result);
161+
filter(this.state.appState, list, result);
158162
this.setState({
159163
componentsToFilter: list,
160164
appFilteredDOM: result
@@ -199,10 +203,10 @@ class App extends Component {
199203
<div id='window'>
200204
<div id='window-nav'>
201205
<span class='window-btn-wrapper'>
202-
<button className='window-btn active' id='reactbtn' onClick={() => { this.handleWindowChange(); }}>GraphQL</button>
206+
<button className='window-btn active' id='graphqlbtn' data-btn='Graphql' onClick={(e) => { this.handleWindowChange(e.target); }}>GraphQL</button>
203207
</span>
204208
<span class='window-btn-wrapper'>
205-
<button className='window-btn' id='graphqlbtn' onClick={() => { this.handleWindowChange(); }}>Component Tree</button>
209+
<button className='window-btn' id='reactbtn' data-btn='React' onClick={(e) => { this.handleWindowChange(e.target); }}>Component Tree</button>
206210
</span>
207211
</div>
208212

@@ -217,7 +221,7 @@ class App extends Component {
217221
) : (
218222
<div class='reactTab'>
219223
<StateContainer clearLog={this.handleClearLog.bind(this)} stateDiffs={this.state.stateDiff} />
220-
<TreeDiagram appState={this.state.appFilteredDOM} handleMouseOver={this.handleMouseOver} handleFilter={this.handleFilter.bind(this)} />
224+
<TreeDiagram appState={this.state.appFilteredDOM.length === 0 ? this.state.appState : this.state.appFilteredDOM} handleMouseOver={this.handleMouseOver} handleFilter={this.handleFilter.bind(this)} />
221225
<StatePropsBox nodeData={this.state.nodeData} />
222226
</div>
223227
)}

0 commit comments

Comments
 (0)