react-component/tree

Do not reset active item, if mouse simply moved

benjaminr-ps opened this issue · 0 comments

Status Quo

Using the keyboard navigation, the tree shows an active active item.

Problem

If the user moves the mouse cursor, the active item is reset.

tree/src/NodeList.tsx

Lines 360 to 362 in 62e0bf0

onMouseMove={() => {
onActiveChange(null);
}}

Use Case

User can select a tree item with mouse cursor, and from there on, continue to use the keyboard navigation.
Please see a sample implementation:
https://codesandbox.io/s/basic-antd-5-0-7-forked-b0nu42?file=/demo.tsx

Hint

Unfortunately, I have to set the focus by hack, to activate the keyboard navigation.
It would be awesome, if tree component supports a interface property, like "focusOnClick".
IMHO, the tree could be focused by default, when clicked. (But not sure about other user's use-cases)