JedWatson / JedWatson/react-select
"menuListRef" is null when referenced in onMenuOpen
Open
Nobody has claimed this yet.
issue/bug-confirmed
menu-bug
- Dominant language
- TypeScript
- Stars
- 28k
- Forks
- 4.1k
- PR merge metrics
- No merged PRs in 30d
Description
Hi.
It seems that onMenuOpen is triggered before menu mounts to the DOM, and as a result we can't synchronously get menuListRef.
Example:
class A extends React.Component {
handleMenuOpen = () => {
console.log(this.selectRef.current?.select?.menuListRef); // it shows null
setTimeout(() => {
console.log(this.selectRef.current?.select?.menuListRef); // it shows an actual element
}, 100);
}
render() {
return (
<Select ref={this.selectRef} onMenuOpen={this.handleMenuOpen} />
)
}
}
Contributor guide
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 at the Select component entry point and trace when onMenuOpen runs relative to menu mounting and menuListRef assignment. Reproduce the issue with the provided React example, then verify that menuListRef is available at the documented callback boundary without relying on setTimeout.
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
- Needs clarification
- Newbie friendliness
- 45/100