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

Using shift+click to select multiple files in the dropbox plugin disables checkboxes in other dropbox folders #4322

Closed
2 tasks done
garyescudero opened this issue Feb 17, 2023 · 3 comments · Fixed by #4415
Labels
Bug Help Wanted Indicates that we’d especially appreciate community input in this issue

Comments

@garyescudero
Copy link

Initial checklist

  • I understand this is a bug report and questions should be posted in the Community Forum
  • I searched issues and couldn’t find anything (or linked relevant results below)

Link to runnable example

No response

Steps to reproduce

It's possible to reproduce this on the uppy demo page (https://uppy.io/examples/dashboard/).

  1. Click dropbox
  2. Sign in
  3. Navigate to a subfolder
  4. Select multiple files by clicking on one file, then shift+clicking on another file
  5. Navigate to a different folder
  6. Some of the files in this folder cannot be selected.

Expected behavior

User should be able to select files.

Actual behavior

User is not able to select files.

Video attached is zipped for file size restriction.

Dashboard — Uppy - Google Chrome 2023-02-17 11-24-34.zip

@tcgj
Copy link
Contributor

tcgj commented Apr 13, 2023

This is also happening with other providers. I've tried to use Google Drive, and the issue far extends beyond this problem.

After a range selection (click 1 file, shift-click another file to select all files in range) is made, the first file selected is permanently set, and clicking (not shift-click) any other file will create a range selection from that first file to the clicked file. Even if you click cancel to reset selection, the first file will be remembered and will still make a range selection. And once you navigate to a different folder, files become un-selectable.

@Murderlon
Copy link
Member

Good catch! Are you interested in making a PR?

It should only be confined to this function:

/**
* Toggles file/folder checkbox to on/off state while updating files list.
*
* Note that some extra complexity comes from supporting shift+click to
* toggle multiple checkboxes at once, which is done by getting all files
* in between last checked file and current one.
*/
toggleCheckbox = (e, file) => {
e.stopPropagation()
e.preventDefault()
e.currentTarget.focus()
const { folders, files } = this.plugin.getPluginState()
const items = this.filterItems(folders.concat(files))
// Shift-clicking selects a single consecutive list of items
// starting at the previous click and deselects everything else.
if (this.lastCheckbox && this.isShiftKeyPressed) {
const prevIndex = items.indexOf(this.lastCheckbox)
const currentIndex = items.indexOf(file)
const currentSelection = (prevIndex < currentIndex)
? items.slice(prevIndex, currentIndex + 1)
: items.slice(currentIndex, prevIndex + 1)
const reducedCurrentSelection = []
// Check restrictions on each file in currentSelection,
// reduce it to only contain files that pass restrictions
for (const item of currentSelection) {
const { uppy } = this.plugin
const restrictionError = uppy.validateRestrictions(
remoteFileObjToLocal(item),
[...uppy.getFiles(), ...reducedCurrentSelection],
)
if (!restrictionError) {
reducedCurrentSelection.push(item)
} else {
uppy.info({ message: restrictionError.message }, 'error', uppy.opts.infoTimeout)
}
}
this.plugin.setPluginState({ currentSelection: reducedCurrentSelection })
return
}
this.lastCheckbox = file
const { currentSelection } = this.plugin.getPluginState()
if (this.isChecked(file)) {
this.plugin.setPluginState({
currentSelection: currentSelection.filter((item) => item.id !== file.id),
})
} else {
this.plugin.setPluginState({
currentSelection: currentSelection.concat([file]),
})
}
}

@Murderlon Murderlon added Help Wanted Indicates that we’d especially appreciate community input in this issue and removed Triage labels Apr 14, 2023
@tcgj
Copy link
Contributor

tcgj commented Apr 14, 2023

It isn't only that function that needs some modifications, but i'll make a PR after I've gotten things working right!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Help Wanted Indicates that we’d especially appreciate community input in this issue
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants