JedWatson / JedWatson/react-select

onBlur never called when parent has been focused

Open
#6,098 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

issue/bug-unconfirmed
Dominant language
TypeScript
Stars
28k
Forks
4.1k
PR merge metrics
No merged PRs in 30d

Description

Hi,

When the parent element of a ReactSelect has been focused, the onBlur is never called on ReactSelect, so clicking outside of the component never close the option menu.

It can be reproduced easily with this:

const nodeRef = useRef<HTMLDivElement | null>(null);
<div
  ref={nodeRef}
  tabIndex={0}
  onMouseDown={() => {
    nodeRef.current?.focus();
  }}
>
  <ReactSelect />
</div>

Another strange thing is that in this situation, onMenuClose is called when we open the menu for the first time, and it's not the case in regular situations.

Thanks,

Contributor guide

Open the contributing guide

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 focus sequence with the provided parent div and ReactSelect snippet, then trace the component's onBlur and onMenuClose handling. Done means clicking outside after the parent has been focused triggers onBlur and closes the option menu without the unexpected initial onMenuClose call.

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
Quiet
Clarity
Mostly clear
Newbie friendliness
55/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.