react-complex-tree icon indicating copy to clipboard operation
react-complex-tree copied to clipboard

onSelectItems fn calls on dragging the item for reorders every time.

Open Nishchit14 opened this issue 2 years ago • 4 comments

Describe the bug When I start dragging the item to re-arrange the order, it always calls the onSelectItems function. On the onSelectItems call I am opening a file in a new tab (similar to vs code experience), due to this side effect the UX experience seems to be poor as the user is not intended to open the file while dragging it for re-order.

To Reproduce

  1. pick up an item to drag
  2. observe the onSelectItems fun

Expected behavior On dragging the item the onSelectItems fn should not be called

Desktop (please complete the following information):

  • OS: iOS
  • Browser: chrome, safari

Nishchit14 avatar Apr 18 '23 18:04 Nishchit14

any help here @lukasbach ? highly appreciated!!

Nishchit14 avatar Apr 25 '23 06:04 Nishchit14

Hi @Nishchit14, can you try to use the onPrimaryAction instead of the onSelectItems handler? That should call in those situations in which you want a call.

lukasbach avatar Apr 25 '23 07:04 lukasbach

Thank you for the reply, Can you please share a doc or example that is available in the codebase? I've searched it but couldn't find anything other than propsonPrimaryAction: (items: TreeItem<T>, treeId: string) => void. I am not sure when this prop fn will get called.

Nishchit14 avatar Apr 25 '23 10:04 Nishchit14

There are no good docs on the exact logic right now, but the intent is that it calls when the user clicks on an item with probably no tree-navigation related intent. The exact logic you can see in the implementation, and is pretty much

  • when shift is not pressed
  • when control is not pressed
  • [when the item is not a folder, or canInvokePrimaryActionOnItemContainer is true]

You can test when it is triggered in this example. If you want to further customize which kind of user interaction triggers what, you can use custom interaction modes for that.

lukasbach avatar May 02 '23 14:05 lukasbach