Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

On searching parent node is not unfolding #49

Closed
nayan826 opened this issue Dec 1, 2019 · 11 comments
Closed

On searching parent node is not unfolding #49

nayan826 opened this issue Dec 1, 2019 · 11 comments

Comments

@nayan826
Copy link

nayan826 commented Dec 1, 2019

On searching a child of a tree parent is not unfolding. Can you please look into this why it is happening. Below is the code

import React,{Component} from 'react';
import './App.css';
import {tree} from './treedata'
import MuiTreeView from 'material-ui-treeview';

class App extends Component {
constructor(props) {
super(props);
this.state = { val : "" }
}
render() {

const handleClick = (event) => {
  this.setState({val : event.target.value})
}
console.log(this.state.val)
return (  
  <div>
    <input onChange={handleClick}></input>
    <MuiTreeView tree = {tree} searchTerm = {this.state.val} softSearch = {tree}/>
    </div>
);

}
}

export default App;

@helfi92
Copy link
Owner

helfi92 commented Dec 1, 2019

Are you seeing an error or something? From just looking at the code, I see that there's extra expaces between the "=" symbol as well as an extra = { tree } at the end.

Instead of <MuiTreeView tree = {tree} searchTerm = {this.state.val} softSearch = {tree}/>, it should probably be <MuiTreeView tree={tree} searchTerm={this.state.val} softSearch />.

@helfi92
Copy link
Owner

helfi92 commented Dec 1, 2019

You can go to https://hassanali.me/material-ui-treeview/ and then click on "View Code" for an example.

@nayan826
Copy link
Author

nayan826 commented Dec 1, 2019

I have tried it with spaces removed but still same issue.
There is no error just parent node is not unfolding. If i search for Child A inside of Parent A then it only shows Parent A instead of Child A underneath Parent A.
image

@helfi92
Copy link
Owner

helfi92 commented Dec 1, 2019

In

<MuiTreeView tree = {tree} searchTerm = {this.state.val} softSearch = {tree}/>,
softSearch = {tree}

is definiely wrong since softSearch should be a boolean, not a tree:

@nayan826
Copy link
Author

nayan826 commented Dec 1, 2019

I recognized that should be true and made it true but still nothing changed

Please check this sandbox link

https://codesandbox.io/s/zen-surf-epnnn?fontsize=14&hidenavigation=1&theme=dark

@helfi92
Copy link
Owner

helfi92 commented Dec 1, 2019

What should I be looked at? I don't see anything specific to material-ui-treeview

Screen Shot 2019-12-01 at 3 01 43 PM

@nayan826
Copy link
Author

nayan826 commented Dec 1, 2019

try again there is unsaved files

@helfi92
Copy link
Owner

helfi92 commented Dec 1, 2019

Ah, ok I see your issue You can use the defaultExpanded prop.

<MuiTreeView defaultExpanded ... />

@nayan826
Copy link
Author

nayan826 commented Dec 1, 2019

But by doing this tree will be opened by default but i want tree to be closed on first render. I don't really want to display whole tree.

@helfi92
Copy link
Owner

helfi92 commented Dec 1, 2019

I see. I don't think we expose a prop for that. There is however a workaround you can do https://codesandbox.io/s/recursing-lumiere-8dl9g.

@nayan826
Copy link
Author

nayan826 commented Dec 1, 2019

This looks great. Thanks

@helfi92 helfi92 closed this as completed Dec 1, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants