shunjizhan / react-folder-tree

A versatile react treeview library that supports custom icons and event handlers
https://www.npmjs.com/package/react-folder-tree
119 stars 46 forks source link

Show toolbar only in clicked folders #100

Open KangSeungKu opened 11 months ago

KangSeungKu commented 11 months ago

I want to display the toolbar only in the clicked folder, is there a way?

Thank you.

jzarei1996 commented 11 months ago

Hi @KangSeungKu . Yes. The solution for your needs is to customize the default wherever you don't want it and disable the defaultOnClick() function. I think you should do these two things:

` const onNameClick = ({ defaultOnClick, nodeData }) => { // defaultOnClick(); ..... };

const FileIcon = ({ onClick: defaultOnClick, nodeData }) => { const { path, name, checked, isOpen, ...restData } = nodeData;

// custom event handler const handleClick = () => { // defaultOnClick(); };

// custom Style return <FaBitcoin onClick={ handleClick } />; };

<FolderTree data={} onChange={onTreeStateChange} iconComponents={{ FileIcon, }} onNameClick={onNameClick} /> `

I hope this solution helps you.