Skip to content
This repository was archived by the owner on Dec 15, 2022. It is now read-only.

Drag multiple items in tree-view - #1179

Merged
ungb merged 37 commits into
atom:masterfrom
UziTech:multi-drag
Feb 10, 2018
Merged

ungb merged 37 commits into
atom:masterfrom
UziTech:multi-drag

Conversation

@UziTech

@UziTech UziTech commented Sep 10, 2017 •

Copy link
Copy Markdown
Contributor

Description of the Change

multi-drag screenshot

  • Allow multi-select to work like it is supposed to

shift + ctrl + click screenshot

Benefits

Multi-select will work like other file explorers

Possible Drawbacks

none

Applicable Issues

Fixes #232
Supersedes and closes #793

@winstliu winstliu self-assigned this Sep 10, 2017
@winstliu

Copy link
Copy Markdown
Contributor

@UziTech what is the purpose of 0f7a4b7?

@UziTech

UziTech commented Sep 10, 2017

Copy link
Copy Markdown
Contributor Author

@50Wliu

When trying to drag multiple files you click and hold on one of the selected files and drag to a folder.

When selecting only a single selected file when multiple are selected you just click on the selected file.

We need to make sure the user is not dragging before deselecting all files except for the one that is clicked on. In order to do that we need to do the deselect on mouseup.

We still want most mouse operations to occur on mousedown. Only when we need to make sure there is no dragging do we do the operation on mouseup.

@Ben3eeE

Ben3eeE commented Sep 16, 2017

Copy link
Copy Markdown
Contributor

I'm signing up for testing here since I tested the original PR.

@andyfleming

Copy link
Copy Markdown

Great work! Let's get this done!

I can't believe we can't drag multiple files in atom yet 😆 .

@UziTech

UziTech commented Oct 6, 2017

Copy link
Copy Markdown
Contributor Author

@Ben3eeE anything holding this up?

@Ben3eeE

Ben3eeE commented Oct 6, 2017

Copy link
Copy Markdown
Contributor

@UziTech Sorry been swamped with other things. I will take a look as soon as I get a chance to, hopefully I will have some time this weekend ⚡️

@UziTech

UziTech commented Oct 19, 2017

Copy link
Copy Markdown
Contributor Author

I rebased again and fixed the merge conflicts in the tests

@UziTech

UziTech commented Oct 27, 2017

Copy link
Copy Markdown
Contributor Author

@Ben3eeE Any way we can get this out the door so I don't have to keep rebasing?

@arthurlacoste

Copy link
Copy Markdown

Please, merge this feature !

anderoonies and others added 10 commits November 15, 2017 07:55
When a directory and its children are being dragged, only drag the directory, not the individual children.
this test guarantees that dragging a directory d and additional files f into a new directory will move the entire directory d discreetly along with any additional files f.
re-enable a metaclick to allow an item to be selected from the multi-selection. change the behavior of drag image building so that there's no collapsing and properly deselects the drag image.
@UziTech

UziTech commented Jan 29, 2018

Copy link
Copy Markdown
Contributor Author

I believe I fixed the issue where a folder would get deselected when dragging over it with files from another Atom window.

I added the class drag-over as well as selected so themes still highlight the folder but only remove the selected class on leave if it also has the drag-over class

@Ben3eeE I manually tested all of those cases on a Windows 10 and they seem to work as expected. One other case I came across that doesn't work but probably should is dropping a selection on a file. I would expect that the selection would be moved into the same folder as the file that is being dropped on, but right now the move operation is just canceled when dropping on a file.

Actual:
screenshot2

Expected:
screenshot

@Ben3eeE

Ben3eeE commented Jan 29, 2018

Copy link
Copy Markdown
Contributor

One other case I came across that doesn't work but probably should is dropping a selection on a file. I would expect that the selection would be moved into the same folder as the file that is being dropped on, but right now the move operation is just canceled when dropping on a file.

Tested this quick and it appears to also be an issue on master so it's not going to block this PR from moving forward. Do you want to create an issue for this?

@UziTech

UziTech commented Jan 29, 2018

Copy link
Copy Markdown
Contributor Author

I just added it to this pr

Comment thread lib/tree-view.coffee Outdated

entryName = path.basename(initialPath)
newPath = "#{newDirectoryPath}/#{entryName}".replace(/\s+$/, '')
newPath = "#{newDirectoryPath}#{path.sep}#{entryName}".replace(/\s+$/, '')

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: could you remove this change and add it in a separate PR? It should also be path.join(newDirectoryPath, entryName).

I ask because I'm also fixing this same line in both #1180 and #1173, so it would probably be better to just submit this change in a different PR.

Comment thread lib/tree-view.coffee
return
e.stopPropagation()

# TODO: meta+click and ctrl+click should not do the same thing on Windows.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is fixing this something that would require a significant rework of the specs?

@UziTech UziTech Jan 29, 2018 •

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes. Any spec that simulates a [ctrl] + [click] on windows, does so by setting e.metaKey to true.

It is also not that big of a deal because in Windows meta(Windows key)+click isn't something people usually do.

Comment thread lib/tree-view.coffee Outdated
@selectMultipleEntries(entryToSelect)
# return early if clicking on a selected entry
if entryToSelect.classList.contains('selected')

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔥 blank line

Comment thread lib/tree-view.coffee Outdated
@roots = []
@selectedPath = null
@selectOnMouseUp = null
@lastFocusedElement = null

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems like this makes more sense as @lastFocusedEntry?

Comment thread lib/tree-view.coffee Outdated
@list.classList.remove('full-menu')
@list.classList.add('multi-select')

toggleMultiSelectMenu: ->

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

toggle generally implies "if on, turn off (and vice versa)". Therefore a better name for this method might be showMultiSelectMenuIfNecessary.

Comment thread lib/tree-view.coffee Outdated
newElement.style.paddingRight = "1em"
dragImage.append(newElement)


Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔥 extra empty line

@winstliu

Copy link
Copy Markdown
Contributor

Going back to your comment here: #1179 (comment)

Perhaps click could be used to combine the two cases?

@UziTech

UziTech commented Jan 29, 2018

Copy link
Copy Markdown
Contributor Author

I could use click but I would still need a variable letting the onClick function know if it should execute otherwise it would deselect a file after selecting it on mousedown. And we do want to use the mousedown function for selecting because someone might want to ctrl+click then just start dragging.

screenshot

@UziTech UziTech mentioned this pull request Feb 2, 2018
@adamreisnz

Copy link
Copy Markdown

Would be great to have this 👍

@winstliu

winstliu commented Feb 3, 2018

Copy link
Copy Markdown
Contributor

Code changes look good to me. @Ben3eeE if you're good with this as well I think it can 🚢?

@Ben3eeE

Ben3eeE commented Feb 6, 2018

Copy link
Copy Markdown
Contributor

@UziTech All good from me when testing on Windows 👍 @ungb is going to go over the test plan on macOS and Linux and merge if all is good.

@ungb

ungb commented Feb 6, 2018

Copy link
Copy Markdown
Contributor

I'm looking into this now. going off test plan in #1179 (comment). I'll merge this once I'm done

@ungb

ungb commented Feb 7, 2018 •

Copy link
Copy Markdown
Contributor

I ran into the following while dragging between two atom windows.

See gif for repro.

error

Repro steps:
Run the following command to create the folders and file

mkdir test1 test2
cd test1 && touch a b c && cd ../test2 && touch a b c && cd ..
atom test1 && atom test2
  1. Drag file a from folder test1 to folder test2 in the other atom window

Atom: 1.23.3 x64
Electron: 1.6.15
OS: Mac OS X 10.12.6
Thrown From: tree-view package 0.222.0

Stack Trace

Uncaught TypeError: Cannot read property 'collapse' of null

At /Users/ungb/github/packages/tree-view/lib/tree-view.coffee:1126

TypeError: Cannot read property 'collapse' of null
    at TreeView.module.exports.TreeView.onDrop (/packages/tree-view/lib/tree-view.coffee:1126:9)
    at /packages/tree-view/lib/tree-view.coffee:206:47)

@UziTech

UziTech commented Feb 7, 2018

Copy link
Copy Markdown
Contributor Author

Nice catch

@ungb

ungb commented Feb 7, 2018 •

Copy link
Copy Markdown
Contributor

Ctrl+click doesn't work on linux.. it seems to just open up the context menu. Shift works fine.
image

@Ben3eeE does this work on windows? I can spend some time testing windows today as well.

After the latest change, everything works great on mac!

@Ben3eeE

Ben3eeE commented Feb 7, 2018

Copy link
Copy Markdown
Contributor

@Ben3eeE does this work on windows?

@ungb It did when I tested. I have not tested on the most recent commit however.

@ungb

ungb commented Feb 9, 2018

Copy link
Copy Markdown
Contributor

@Ben3eeE I think my issues is because I'm running on a VM on mac and it's doing something weird. I'll take a look when I get home on my windows machine and then try to see if I spin up a VM on there for linux. So far everything looks good, but every time I hit ctrl+click it opens up the context menu. I'm noticing this on my VM and happens on the desktop on windows too.

@Ben3eeE

Ben3eeE commented Feb 9, 2018

Copy link
Copy Markdown
Contributor

@ungb I have Ubuntu installed so I can test this on Linux if you run into more issues because of testing in a VM.

@ungb

ungb commented Feb 10, 2018

Copy link
Copy Markdown
Contributor

I've tested this and everything looks good to me. I'm going to merge this. I'm going to follow up with the team later on the appveyor failure so we can get this into master.

@ungb
ungb merged commit 3424331 into atom:master Feb 10, 2018
@UziTech

UziTech commented Feb 10, 2018

Copy link
Copy Markdown
Contributor Author

hallelujah-gif-15

@jonathan-dejong

Copy link
Copy Markdown

Any news on this?
From what I can tell with Atom 1.26.1 it is not merged yet.

@Ben3eeE

Ben3eeE commented May 8, 2018

Copy link
Copy Markdown
Contributor

@jonathan-dejong This is merged but it's not released yet because the tests are failing on atom/atom when upgrading the tree-view. You may want to subscribe to atom/atom#17088 for updates on when it will be available in a released version of Atom.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Move multiple files.

10 participants