-
Notifications
You must be signed in to change notification settings - Fork 2.5k
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
Fix for DnD files to main area #8739 #8927
Conversation
This fix looks reasonable, but it may not be addressing the root problem. It seems like the real issue is that selection might be expected to happen on mouse down, or if not that, then at least theia/packages/filesystem/src/browser/file-tree/file-tree-widget.tsx Lines 106 to 129 in 39887bf
|
@colin-grant-work - Totally agreed on your point, i have looked into fixing under handleDragStartEvent, But the problem i faced is Even if we select nodes in handleDragStart, those will always will be reset by handleDragEnter below, The below code is for updating selection when dragging files and hovering to/inside a folder theia/packages/filesystem/src/browser/file-tree/file-tree-widget.tsx Lines 131 to 139 in c79e9d4
I felt if we could have two kinds of node selection states like focused nodes and selected nodes (like in vscode), that would be better to address these issues. |
Hm... Yes, I see what you mean about the drag enter handler resetting the selection immediately. I agree that two focus/selected states might be helpful, and in fact there is code in various tree related files that anticipates a focused state. theia/packages/core/src/browser/tree/tree-selection.ts Lines 133 to 135 in 335273b
theia/packages/core/src/browser/tree/tree-widget.tsx Lines 904 to 906 in 335273b
but that option isn't really exploited in any of the tree state management that I've seen, and implementing that is likely too much to ask for this PR 😄. It looks like there's some confusion about how the
But the current implementation of the command ignores anything passed and instead just refers to the selection state: theia/packages/navigator/src/browser/navigator-contribution.ts Lines 350 to 360 in 335273b
I think that the reference to the selection state is to support invocation from a context menu. In any case, it seems to me that the part of this that is least consistent with VSCode's behavior is the setting of the selection to the containing folder on any drag action - that simply doesn't happen in VSCode. I also don't see that that it's necessary, other than as a visual guide (which VSCode provides via focus, rather than selection), since on drop, the container is calculated anyway: theia/packages/filesystem/src/browser/file-tree/file-tree-widget.tsx Lines 162 to 183 in 335273b
I get reasonable behavior with the following changes:
The visual guide of the selected directory is lost, but the behavior is correct - and the visual guide should really be provided by other means. So the decision is whether to work around it for now, as you have in the code you've submitted, or fix it at the source, but leave work to be done on focus states in trees. If you're willing to take a stab at providing focus behavior in this case, that would be awesome, otherwise I'm probably inclined to accept your code - I don't foresee any negative side effects - and make a ticket specifically for focus behavior. |
@colin-grant-work - As you were saying above using selection for the visual guide is what making the behaviour odd. I will try to take a look into providing a separate focus behaviour for tree in a separate PR. That way the visual guides and selection can be in consistent with the VSCode behaviour and these kind of issues can be fixed. |
Sounds good. In that case, the only change I'd request here is that you use the theia/packages/core/src/browser/tree/tree-selection.ts Lines 129 to 131 in 7e8992b
In the end, it's the same, but using the function ensures that if we later change how selection is handled (e.g. not with a field on the node itself), the change is carried through consistently. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've confirmed that it fixes the issue #8739 👍
I verified the following:
- drag-and-drop a file from the explorer to the main-area
- drag-and-drop multiple files from the explorer to the main-area
@balajiv113 please resolve the conflicts, I do not think it'll be on time for today's release, but we can merge shortly afterwards. |
Signed-off-by: Balaji V <[email protected]>
@vince-fugnitto - Conflicts are resolved 👍 |
@balajiv113 thank you for your contribution! |
Signed-off-by: Balaji V [email protected]
What it does
Fixes #8739
The cause of the issue is FileNavigatorCommands.OPEN command opens the file based on tree widget selections, before dropping in editor the selection was not updated correctly in navigator-widget.
The below changes updates the tree selection and then fires the FileNavigatorCommands.OPEN command
How to test
Review checklist
Reminder for reviewers