Skip to content

Unexpected call to onMenuClose on input blur. #3876

@rcgillet

Description

@rcgillet

There is a call to onMenuClose on every input blur, even when the menu has already been closed from another action.

Steps to reproduce:

  1. Pass in an onBlur and onMenuClose function to the Select component.
  2. Open the menu and make a selection. (onMenuClose is fired)
  3. Hit tab or a similar action that would take the focus off of the input. (Both onBlur and onMenuClose are fired)

CodeSandbox reproducing the issue: https://codesandbox.io/s/admiring-bardeen-pu0rg

I was looking through the codebase and found that onMenuClose is being called regardless of the value of menuIsOpen. Link to code

Adding a conditional for menuIsOpen should fix the issue I believe. I would be happy to submit a PR if you believe that the approach I am proposing makes sense.

Metadata

Metadata

Assignees

No one assigned

    Labels

    issue/bug-unconfirmedIssues that describe a bug that hasn't been confirmed by a maintainer yetissue/reviewedIssue has recently been reviewed (mid-2020)

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions