On selection callback?
Closed this issue · 5 comments
I am not sure if this exists, but I was looking through the code and was unable to find a callback when you click on a file or folder that returns the file object.
<FileBrowser onSelectFile={this.handleSelectFile} onSelectFolder={this.handleSelectFolder} />
Hello.
I need to get the path to a selected folder or file.
onSelectFile is working fine but onSelectFolder event is returning undefined, any sugestions please?
Thanks
Duplicates: #143
Ok looking at the code I've discovered how the onSelect callback works.
If you files look like
/a/b/c.txt, /a/b/d.txt
, then you will get undefined for the folder calls because no folders have been defined.
If you have /a/, a/b/, /a/b/c.txt, /a/b/d.txt
then you will not get undefined but the folder you are looking for.
The problem lies in https://github.com/uptick/react-keyed-file-browser/blob/master/src/browser.js#L178
where .find is looking for an exact match.
I would argue that a user should not have to specify all the folders and if a prefix exists, return a select with a folder and no modified, size. I'll create a PR to do just this.
also solved by #149