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
merged 37 commits into from
Feb 10, 2018
Merged

Drag multiple items in tree-view #1179

merged 37 commits into from
Feb 10, 2018

Conversation

UziTech
Copy link
Contributor

@UziTech UziTech commented Sep 10, 2017

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
Contributor

@UziTech what is the purpose of 0f7a4b7?

@UziTech
Copy link
Contributor Author

UziTech commented Sep 10, 2017

@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
Copy link
Contributor

Ben3eeE commented Sep 16, 2017

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

@andyfleming
Copy link

Great work! Let's get this done!

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

@UziTech
Copy link
Contributor Author

UziTech commented Oct 6, 2017

@Ben3eeE anything holding this up?

@Ben3eeE
Copy link
Contributor

Ben3eeE commented Oct 6, 2017

@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
Copy link
Contributor Author

UziTech commented Oct 19, 2017

I rebased again and fixed the merge conflicts in the tests

@UziTech
Copy link
Contributor Author

UziTech commented Oct 27, 2017

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

@arthurlacoste
Copy link

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
Copy link
Contributor Author

UziTech commented Jan 29, 2018

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
Copy link
Contributor

Ben3eeE commented Jan 29, 2018

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
Copy link
Contributor Author

UziTech commented Jan 29, 2018

I just added it to this pr

@@ -869,7 +873,7 @@ class TreeView
return

entryName = path.basename(initialPath)
newPath = "#{newDirectoryPath}/#{entryName}".replace(/\s+$/, '')
newPath = "#{newDirectoryPath}#{path.sep}#{entryName}".replace(/\s+$/, '')
Copy link
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.

return
e.stopPropagation()

# TODO: meta+click and ctrl+click should not do the same thing on Windows.
Copy link
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?

Copy link
Contributor Author

@UziTech UziTech Jan 29, 2018

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.

else if e.metaKey or (e.ctrlKey and process.platform isnt 'darwin')
@selectMultipleEntries(entryToSelect)
# return early if clicking on a selected entry
if entryToSelect.classList.contains('selected')

Copy link
Contributor

Choose a reason for hiding this comment

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

🔥 blank line

@@ -38,6 +38,8 @@ class TreeView
@emitter = new Emitter
@roots = []
@selectedPath = null
@selectOnMouseUp = null
@lastFocusedElement = null
Copy link
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?

# menu with only items that make sense for multi select functionality
showMultiSelectMenu: ->
@list.classList.remove('full-menu')
@list.classList.add('multi-select')

toggleMultiSelectMenu: ->
Copy link
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.

newElement.style.paddingRight = "1em"
dragImage.append(newElement)


Copy link
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
Contributor

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

Perhaps click could be used to combine the two cases?

@UziTech
Copy link
Contributor Author

UziTech commented Jan 29, 2018

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

Would be great to have this 👍

@winstliu
Copy link
Contributor

winstliu commented Feb 3, 2018

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

@Ben3eeE
Copy link
Contributor

Ben3eeE commented Feb 6, 2018

@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
Copy link
Contributor

ungb commented Feb 6, 2018

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

@ungb
Copy link
Contributor

ungb commented Feb 7, 2018

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
Copy link
Contributor Author

UziTech commented Feb 7, 2018

Nice catch

@ungb
Copy link
Contributor

ungb commented Feb 7, 2018

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
Copy link
Contributor

Ben3eeE commented Feb 7, 2018

@Ben3eeE does this work on windows?

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

@ungb
Copy link
Contributor

ungb commented Feb 9, 2018

@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
Copy link
Contributor

Ben3eeE commented Feb 9, 2018

@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
Copy link
Contributor

ungb commented Feb 10, 2018

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
Copy link
Contributor Author

UziTech commented Feb 10, 2018

hallelujah-gif-15

@jonathan-dejong
Copy link

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

@Ben3eeE
Copy link
Contributor

Ben3eeE commented May 8, 2018

@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