Choosing root in FileBrowserComponent ComboBox navigates to wrong folder

We have a user reporting that selecting one of the roots (e.g. “Music”) in FileBrowserComponent’s ComboBox sometimes makes the filelist show a wrong folder (e.g. the “Pictures” folder).

I’m guessing his issue is related to whether some network drive is mapped at the creation of the FileBrowserComponent. I have been able to reproduce it in the DemoRunner in the DialogsDemo. Steps to reproduce (on Windows 10):

  1. Click the “‘Load’ File Browser” button
  2. Click the down arrow symbol in the ComboBox and verify that at least one mapped network drive is shown
  3. Disconnect this network drive (in Windows Explorer right click network drive and choose “Disconnect”)
  4. Click “Music” in the ComboBox list
  5. The filelist in the FileBrowserComponent will now show the “Pictures” folder

The reason for this behavior is:

  1. The ComboBox is populated in the constructor of FileBrowserComponent (through call to resetRecentPaths() which calls getRoots() to get the roots to add)
  2. When clicking an entry in the ComboBox list, updateSelectedPath() makes a new call to getRoots() which will return another list of roots than the one shown in the ComboBox
  3. The entries in the ComboBox list and the list returned by getRoots() are thus out of sync

The best fix for this would probably be if FileBrowserComponent could automatically update the roots if any drives appear/disappear. An easier fix could be to make FileBrowserComponent use a cached version of the roots list in updateSelectedPath() to make sure the two lists are always identical.

This also happens if inserting/removing a USB memory stick (probably a more common user action).

But wouldn’t that allow selecting the no-longer-connected drive? Better to detect and respond to a change in drives by updating the list as soon as possible, assuming that’s easily done.

Yes - I agree.

If this requires too much effort, another (not as elegant) solution could be to populate the ComboBox list every time it is shown (by inheriting ComboBox and overriding showPopup()). I don’t know how easy this would be, but at least it shouldn’t require any OS specific code.