react-component / react-component/tree
In jest environment: Expand by clicking switcher stays in motion and does not work
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 1.3k
- Forks
- 490
- Avg merge
- 3d 17h
- Merged PRs (30d)
- 5
Description
I have a helper function that expands a tree node (node1) by clicking on the switcher element.
- The onExpand handler is invoked with expanded = true.
- But I noticed that the tree is still animation mode. Reasons it is still in animation mode:
-
The child nodes of the expanded node1 are still inside a div element
<div class="ant-tree-treenode-motion">{my 3 child treeNodes are here}</div> -
In the same test, I try to expand another node (node2) but it does not expand. I debugged and learned that the Tree component rejects node2 expand (Tree's expand handler is correctly invoked) because of the below code ...
var key = treeNode.key, expanded = treeNode.expanded; // Do nothing when motion is in progress if (listChanging) { return; } -
I also debugged further and went into the
rc-motioncode. The hook useStepQueue's below code is invoked and the requestAnimationFrame is canceled (I am not sure if this is normal or not). But the step never moved forward from "NONE"
-
React.useEffect(function () {
return function () {
cancelNextFrame();
};
}, []);
- I studied the test code in this repo. The test clicks on a switcher and makes sure the handler is invoked. It does not test if the tree is in animation mode or not. I have written this code to make sure the Tree is not animating:
isAnimating: (tree: HTMLElement) => {
return !!tree.querySelector('.ant-tree-treenode-motion');
},
We use the Tree component a lot in our UI and we need to test our features. Appreciate if you guys can help.
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reproducing the helper test that clicks a Tree switcher and checks for the ant-tree-treenode-motion element. Read the Tree expand handler around the listChanging guard and inspect rc-motion's useStepQueue behavior, especially the requestAnimationFrame cleanup. Done means expansion finishes in the test and a subsequent node expansion is accepted.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- react, typescript
- Domain
- frontend, testing-qa
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 35/100