react-component / react-component/tree-select

in antd v4 clicking a node triggers onDropdownVisibleChange

Open
#230 0 comments 3 reactions 0 assignees View on GitHub

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

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.