Skip to content

Commit

Permalink
Merge pull request electron#9610 from shubham2892/incorrect-file-exte…
Browse files Browse the repository at this point in the history
…nsion-with-showSaveDialog-fix

Fix incorrect extension when filters is used
  • Loading branch information
kevinsawicki authored Jun 15, 2017
2 parents 1602c07 + 15dd0eb commit e8911fe
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions atom/browser/ui/file_dialog_mac.mm
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ void SetAllowedFileTypes(NSSavePanel* dialog, const Filters& filters) {
if ([file_type_set count])
file_types = [file_type_set allObjects];

[dialog setExtensionHidden:NO];
[dialog setAllowedFileTypes:file_types];
}

Expand Down Expand Up @@ -75,15 +76,19 @@ void SetupDialog(NSSavePanel* dialog,
}
}

if (settings.filters.empty()) {
[dialog setAllowsOtherFileTypes:YES];
} else {
// Set setAllowedFileTypes before setNameFieldStringValue as it might
// override the extension set using setNameFieldStringValue
SetAllowedFileTypes(dialog, settings.filters);
}

if (default_dir)
[dialog setDirectoryURL:[NSURL fileURLWithPath:default_dir]];
if (default_filename)
[dialog setNameFieldStringValue:default_filename];

if (settings.filters.empty())
[dialog setAllowsOtherFileTypes:YES];
else
SetAllowedFileTypes(dialog, settings.filters);
}

void SetupDialogForProperties(NSOpenPanel* dialog, int properties) {
Expand Down

0 comments on commit e8911fe

Please sign in to comment.