denimar/deni-react-treeview

onSelectItem called when clicking on container (selectRow=false)

Closed this issue · 2 comments

When selectRow is disabled and the user is clicking in the container of a node but outside of the text and icon area, the onSelectItem is called. This is somehow misleading, since the node isn't selected internally (in the library). This can be seen in https://denimar.github.io/deni-react-treeview/examples/#/onselectItem when clicking on a row in the "white space" and not on the names.

My use case is the following: I'm using the library to create a file picker. I have a button that should only be enabled if the user has selected a leaf/file and disabled when clicking on folders. However, with the above behavior, this is broken. Consider the following steps:

  1. User selects a file node (by clicking on the name area)
  2. Button gets enabled
  3. User selects a folder node (by clicking on the name area)
  4. Button gets disabled
  5. User accidentally clicks on a file row (by clicking outside of the name area)
  6. Button gets enabled and user clicks it => visually selected is the folder but my local state contains the file as the selectedNode

I can easily overcome this, but it sounds like a bug to me

Hi Xenia, I think it is working now and released in version "0.0.2.1".
Thank you!

Thanks for the quick fix!