Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot see hidden folders with runtime.OpenDirectoryDialog #2454

Open
davidnewhall opened this issue Mar 6, 2023 · 3 comments · May be fixed by #3904
Open

Cannot see hidden folders with runtime.OpenDirectoryDialog #2454

davidnewhall opened this issue Mar 6, 2023 · 3 comments · May be fixed by #3904
Labels
awaiting feedback More information is required from the requestor Bug Something isn't working

Comments

@davidnewhall
Copy link

Is your feature request related to a problem? Please describe.

Hello,

I want to select a hidden directory when using the runtime.OpenDirectoryDialog method, but they do not appear.

Sample code:

	dir, err := wailsRuntime.OpenDirectoryDialog(a.ctx, wailsRuntime.OpenDialogOptions{
		DefaultDirectory:     a.config.Path,
		Title:                id,
		CanCreateDirectories: true,
		ShowHiddenFiles:      true,
	})

None of the .folders in my home ~ appear.

Describe the solution you'd like

The ShowHiddenFiles member could also control hidden folders. I'd be fine with that, but even better would be a new member for ShowHiddenFolders.

Describe alternatives you've considered

Could probably use a directory browser from another module, but have not tried.

Additional context

Testing on MacOS 12.6, go 1.19. Thanks!

@davidnewhall davidnewhall added the Enhancement New feature or request label Mar 6, 2023
@leaanthony
Copy link
Member

Yeah, good catch - showHiddenFiles works for both directories and files. However it's disabled for directory selection. Confirmed bug!

@leaanthony leaanthony added Bug Something isn't working TODO The issue is ready to be developed and removed Enhancement New feature or request labels Mar 7, 2023
@acanewby
Copy link

acanewby commented May 22, 2023

Hi - I don't have the wherewithall to fix this, but I think I can see where it's happening (at least on macOS):

In v2/internal/frontend/desktop/darwin/dialog.go you have this:

func (f *Frontend) OpenDirectoryDialog(options frontend.OpenDialogOptions) (string, error) {
	results, err := f.openDialog(&options, false, false, true)
	if err != nil {
		return "", err
	}
	var selected string
	if len(results) > 0 {
		selected = results[0]
	}
	return selected, nil
}

The &options argument to f.openDialog() includes the showHiddenFiles flag correctly. Good
The third argument to f.openDialog() (allowfiles) is false. Good
The fourth argument to f.openDialog() (allow directories) is true. Good

But, if I follow the call stack, in v2/internal/frontend/desktop/darwin/WailsContext.m you have this:

-(void) OpenFileDialog :(NSString*)title :(NSString*)defaultFilename :(NSString*)defaultDirectory :(bool)allowDirectories :(bool)allowFiles :(bool)canCreateDirectories :(bool)treatPackagesAsDirectories :(bool)resolveAliases :(bool)showHiddenFiles :(bool)allowMultipleSelection :(NSString*)filters {
    
    
    // <snip/>

    // Filters - semicolon delimited list of file extensions
    if( allowFiles ) {
        
		// <snip/>
        
        [dialog setAllowsMultipleSelection: allowMultipleSelection];
        [dialog setShowsHiddenFiles: showHiddenFiles];

    }

    // </snip>
    
}

So, as far as I can tell, because OpenFileDialog has been invoked with allowFiles: false, the setShowsHiddenFiles message will never be sent when opening a directory dialog, presumably leaving OpenFileDialog with the default behavior of not showing hidden files.

Would the fix be as simple as moving [dialog setShowsHiddenFiles: showHiddenFiles]; outside the if( allowFiles ) {} clause?

@leaanthony
Copy link
Member

@davidnewhall
Please try the above PR to see if this fixes your problem. If you are unsure how to do this, please follow this guide. Let us know how you get on 👍

@leaanthony leaanthony added awaiting feedback More information is required from the requestor and removed TODO The issue is ready to be developed labels Nov 23, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
awaiting feedback More information is required from the requestor Bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants