uptick / react-keyed-file-browser

Folder based file browser given a flat keyed list of objects, powered by React.
MIT License
298 stars 144 forks source link

onSelectFolder returns folder from file path instead of undefined #148

Closed harsh-tamr closed 3 years ago

harsh-tamr commented 3 years ago

Fixes: https://github.com/uptick/react-keyed-file-browser/issues/115

If your 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 get 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 in all the files.

I would argue that a user should not have to specify all the folders and if a prefix exists. The onSelect callback should return a folder with 0 for modified and size.

harsh-tamr commented 3 years ago

@bor3ham @scaredcat @roymfibo @jlo-1