Expand without select #289
-
Is it possible to expand a node without also selecting it? I am using the "click-arrow-to-expand" interaction mode, so there is no click on the actual tree item. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
If you just want to expand an item programmatically, there is a But if you want to completely customize the default behavior for what happens when the user clicks on an item, you can implement an custom interaction mode: https://rct.lukasbach.com/docs/guides/interaction-modes#custom-interaction-modes It should probably work to just remove all action.xx calls that do something with selections from there. |
Beta Was this translation helpful? Give feedback.
Thank you for the reply. Your notes made me dive deeper and i actually went another route for this as i was also using
renderItemArrow
.I noticed that the
onClick
from arrowProps has anactions.selectItem()
by default (https://vscode.dev/github/lukasbach/react-complex-tree/blob/main/packages/core/src/treeItem/useTreeItemRenderContext.ts#L187-L188). I just changed that implementation to:renderItemArrow={({ item, context }) => renderItemIcons( item, { ...context, arrowProps: { ...context.arrowProps, onClick: () => context.toggleExpandedState() } } )}