react-component / react-component/tree-select
in antd v4 clicking a node triggers onDropdownVisibleChange
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 312
- Forks
- 204
- Avg merge
- 37m
- Merged PRs (30d)
- 1
Description
It's no longer possible to control the open state with treeExpandedKeys={expandedKeys} and onDropdownVisibleChange={onDropdownVisibleChange}
I wish to keep the component open after they click on a parent node
but onSelect is called before onDropdownVisibleChange
Example code
const [expandedKeys, setExpandedKeys] = useState<string[]>([])
...
const onDropdownVisibleChange = (visible: boolean) => {
setDropdownVisible(visible) // this gets triggered on a node click
}
const onSelect = async (value: string, node: DataNode) => {
if (node.isLeaf) {
// update
setDropdownVisible(false)
} else {
setExpandedKeys(symmetricDifference(expandedKeys, [value]))
setDropdownVisible(true) // this doesn't work because onDropdownVisibleChange gets called after
}
}
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 example with controlled treeExpandedKeys and the onSelect/onDropdownVisibleChange callbacks, then trace their event order. Done when selecting a parent keeps the component open while selecting a leaf can close it.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- react, typescript
- Domain
- frontend
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100