Help with bug in NSOpenPanel - Can't enable files that are not part of the initial filter set

In our app, we allow the user to open files using the native NSOpenPanel API. In the open dialog, we have an accessory view to filter the set of enabled files based on file type. The first filter in the list (i.e. the default filter), is "all <appname> files", and last filter in the list is "All Files". 

In macOS 10.14 and earlier, switching to the "All Files" filter successfully enabled all files, even ones not categorized as "<appname> files". However, starting with macOS 10.15, this no longer works as expected - switching to the "All Files" filter only enables files considered "<appname> files".

After investigation and debugging, we determined that setting the initial filter to "All Files" produced the expected results, giving us the following conclusion: 

In 10.15, a file will only appear enabled in the dialog BOTH of the following are true:
  1. shouldEnableURL returns true for the file

  2. The file belongs to the set of valid items in the initial filter


In other words:
  • In 10.14, shouldEnableURL was the only thing that determined whether or not a file should appear enabled

  • In 10.15, an additional factor is now involved (checking against the initial filter set)

As you can see, we ultimately do not have overall control over which files will appear enabled. The only thing we pass to the OS is shouldEnableURL, so it seems the OS is caching the filter after it is initially set.

Even though making "All Files" the initial filter solves the problem, it is a last resort fix due to various reasons, and isn't ideal for us.

Is there a workaround?




How are you configuring and opening your save panel?

Is your app sandboxed? As of 10.15 all apps get the sandboxed version of the open and save panels.

How do you set your "All Files" filter - are you using allowsOtherFileTypes or setting allowedContentTypes to an empty array?
I am encountering a similar problem. I believe that the panel is not treating your first filter specially, but rather it is caching the results returned by shouldEnableURL to avoid making multiple calls for the same URL. Sounds like a good idea, except for delegates that change their behavior as yours does. How clever of Apple to introduce this incompatible change without documenting it or providing a way to flush the cache.

Calling validateVisibleColumns appears to fix the problem.

Help with bug in NSOpenPanel - Can't enable files that are not part of the initial filter set
 
 
Q