react-arborist icon indicating copy to clipboard operation
react-arborist copied to clipboard

How to programmatically unfocus node(s)?

Open joshmarnold opened this issue 2 years ago • 4 comments
trafficstars

Is there a way to programmatically unfocus a node without resorting to setting a bogus one? This obviously isn't the right way to go about it, since I can't get rid of the console log (which definitely is not desired).

CleanShot 2022-12-09 at 08 03 11@2x

It also seems that I'm having to "unfocus" when deselecting nodes using tree.deselectAll(). Since there isn't an unfocus method, I'm having to use a bogus value which then outputs in the console.

Could we

  1. Remove the console log
  2. add an unfocus method

joshmarnold avatar Dec 08 '22 13:12 joshmarnold

Yes, we can certainly remove that console.log. And yes, we can add a .blur() method on the tree. I'm not sure whether it should return focus to the tree container, or to document.body or something else?

Can you explain your use case? What is it youre trying to do by removing focus?

jameskerr avatar Dec 09 '22 22:12 jameskerr

You can also remove focus by simply focusing on a different element.

Is it a styling concern? If you are styling the nodes with .isFocused, you can change the css selector to use :focus and that will only be applied when the tree has focus.

jameskerr avatar Dec 09 '22 22:12 jameskerr

I removed that console.log in this PR: https://github.com/brimdata/react-arborist/pull/79

jameskerr avatar Dec 12 '22 19:12 jameskerr

Thank you. I apologize for the delay in getting back to you. I have been busy, but I will respond with more details shortly.

Great work on this library btw!

joshmarnold avatar Dec 13 '22 00:12 joshmarnold