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

[electron] File dialog filters do not work #9242

Closed
kittaakos opened this issue Mar 23, 2021 · 1 comment · Fixed by #9659
Closed

[electron] File dialog filters do not work #9242

kittaakos opened this issue Mar 23, 2021 · 1 comment · Fixed by #9659
Labels
good first issue good first issues for new contributors

Comments

@kittaakos
Copy link
Contributor

Bug Description:

I found this bug when reviewing #9184. Although a filter is correctly configured:

const props: OpenFileDialogProps = {
title: VSXExtensionsCommands.INSTALL_FROM_VSIX.dialogLabel,
openLabel: 'Install',
filters: { 'VSIX Extensions (*.vsix)': ['vsix'] },
canSelectMany: false
};

It has no effect, as we always use the * filter. This code should be changed:

const filters: FileFilter[] = [{ name: 'All Files', extensions: ['*'] }];
if (props.filters) {
filters.push(...Object.keys(props.filters).map(key => ({ name: key, extensions: props.filters![key] })));
}

Expected:

diff --git a/packages/filesystem/src/electron-browser/file-dialog/electron-file-dialog-service.ts b/packages/filesystem/src/electron-browser/file-dialog/electron-file-dialog-service.ts
index 10729331d5..eff76250aa 100644
--- a/packages/filesystem/src/electron-browser/file-dialog/electron-file-dialog-service.ts
+++ b/packages/filesystem/src/electron-browser/file-dialog/electron-file-dialog-service.ts
@@ -93,9 +93,11 @@ export class ElectronFileDialogService extends DefaultFileDialogService {
     protected toDialogOptions(uri: URI, props: SaveFileDialogProps | OpenFileDialogProps, dialogTitle: string): electron.FileDialogProps {
         const title = props.title || dialogTitle;
         const defaultPath = FileUri.fsPath(uri);
-        const filters: FileFilter[] = [{ name: 'All Files', extensions: ['*'] }];
+        const filters: FileFilter[] = [];
         if (props.filters) {
             filters.push(...Object.keys(props.filters).map(key => ({ name: key, extensions: props.filters![key] })));
+        } else {
+            filters.push({ name: 'All Files', extensions: ['*'] });
         }
         return { title, defaultPath, filters };
     }

Steps to Reproduce:

Additional Information

  • Operating System:
  • Theia Version:
@kittaakos kittaakos added the good first issue good first issues for new contributors label Mar 23, 2021
@scottaxcell
Copy link

@kittaakos this looks like a good first issue to get my feet wet. Can I help with this issue?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue good first issues for new contributors
Projects
None yet
2 participants