diff --git a/ui/component/common/file-selector.jsx b/ui/component/common/file-selector.jsx index fda7b11d7..bd1729d31 100644 --- a/ui/component/common/file-selector.jsx +++ b/ui/component/common/file-selector.jsx @@ -47,7 +47,24 @@ class FileSelector extends React.PureComponent { }; handleDirectoryInputSelection = () => { - remote.dialog.showOpenDialog({ properties: ['openDirectory'] }).then((result) => { + let defaultPath; + let properties; + let isWin = process.platform === 'win32'; + let type = this.props.type; + + if (isWin === true) { + defaultPath = process.env.HOME || process.env.HOMEPATH || process.env.USERPROFILE; + } + + if (type === 'openFile') { + properties = ['openFile']; + } + + if (type === 'openDirectory') { + properties = ['openDirectory']; + } + + remote.dialog.showOpenDialog({ properties, defaultPath }).then((result) => { const path = result && result.filePaths[0]; if (path) { // $FlowFixMe @@ -82,7 +99,11 @@ class FileSelector extends React.PureComponent { autoFocus={autoFocus} button="primary" disabled={disabled} - onClick={type === 'openDirectory' ? this.handleDirectoryInputSelection : this.fileInputButton} + onClick={ + type === 'openDirectory' || type === 'openFile' + ? this.handleDirectoryInputSelection + : this.fileInputButton + } label={__('Browse')} /> } diff --git a/ui/component/publishFile/view.jsx b/ui/component/publishFile/view.jsx index cc57aca89..b53b7720c 100644 --- a/ui/component/publishFile/view.jsx +++ b/ui/component/publishFile/view.jsx @@ -325,6 +325,7 @@ function PublishFile(props: Props) { {showFileUpload && ( <>