@uppy/dashboard: My Device button respects fileManagerSelectionType#6258
@uppy/dashboard: My Device button respects fileManagerSelectionType#6258EnverUsta wants to merge 4 commits intotransloadit:mainfrom
Conversation
…ck handler based on fileManagerSelectionType
…rity in AddFiles component
… AddFiles component
|
| role="tab" | ||
| tabIndex={0} | ||
| data-uppy-super-focusable | ||
| onClick={this.triggerFileInputClick} |
There was a problem hiding this comment.
having gone through the code now I suspect this was hardcoded because renderMyDeviceAcquirer can only allow one selection at a time , i.e. files or folders but can't handle fileManagerSelectionType: 'both' unlike renderDropPasteBrowseTagline which literally renders 2 buttons so in case of "both" it would render 2 buttons
one for selecting file and another for selecting folder and that this not possible for renderMyDeviceAcquirer because it's just a single button
There was a problem hiding this comment.
Yes, exactly, it's not possible to support both; however, we can still support the folder selection. As you said, probably they put as hardcoded since it's not possible to handle both scenarios. But if we hardcode like that, we miss the folder option for no reason. In our application we needed folder option, that was the first reason I investigated this problem.
| const triggerMyDeviceInputClick = | ||
| this.props.fileManagerSelectionType === 'folders' | ||
| ? this.triggerFolderInputClick | ||
| : this.triggerFileInputClick |
There was a problem hiding this comment.
this looks good but because for the reasons which I described in
the previous comment it misses the the "both" case , so that might still be considered as a bug ?
There was a problem hiding this comment.
@qxprakash , I also noticed it but it's impossible to handle both scenarios in one button. Even in the dashboard if you go with both option, then you need to put both buttons such as: browse files and browse folders.
Fixes #6256
Problem
When
fileManagerSelectionTypeis set to'folders', clicking the My Device tab/buttonstill opens the file picker instead of the folder picker.
The inline "browse" link in the tagline correctly respects the setting, but
renderMyDeviceAcquirerinAddFiles.tsxalways calledtriggerFileInputClickregardless of the
fileManagerSelectionTypeprop.Solution
renderMyDeviceAcquirernow readsfileManagerSelectionTypeand callstriggerFolderInputClickwhen set to'folders', ortriggerFileInputClickfor
'files'and'both'.For
'both'mode, the button defaults to file selection because a singleHTML
<input>cannot handle both files and folders simultaneously(
webkitdirectoryis all-or-nothing). The folder picker remains accessiblevia the tagline's "browse folders" link.