react-select icon indicating copy to clipboard operation
react-select copied to clipboard

onMenuClose fires on blur even though menu is closed

Open PSoltes opened this issue 3 years ago • 4 comments

There is a call to onMenuClose on every select blur, even when the menu is closed. It was marked as solved in #3876.

Steps to reproduce:

  • open codesanbox - https://codesandbox.io/s/react-select-onclosemenufires-on-blur-c2jwo?file=/src/index.tsx
  • remove option from select by clicking x on it. Select focuses without menu opening (or just get select to be focused somehow)
  • blur the focus by clicking outside of select
  • console logs that onMenuClose fired

Thanks for all work that you put into the package.

PSoltes avatar Jun 04 '21 17:06 PSoltes

I have a same issue

walt1992 avatar Sep 14 '21 11:09 walt1992

@PSoltes You can make your own component wrapper for the same with using MultiValueRemove and pass same props with overriding the onClick, it will work .

rohanvachheta avatar Nov 20 '21 06:11 rohanvachheta

I have a same issue (not about MultiValueRemove, but called onMenuClose even though menu is closed)

Steps to reproduce:

  • open codesanbox ( thanks @PSoltes )
  • click Input -> menu popup shows up
  • enter 'Esc' -> menu popup closed and onMenuClose fired
  • blur the focus by clicking outside of select -> onMenuClose fired again even if menu popup already closed

I think onMenuClosed function should be called only one time when menu popup closed literally.

dooyou21 avatar Apr 14 '22 09:04 dooyou21

This seems like it is still an issue.

I wonder if we need a check that the menu is actually still open around this code before we run onMenuClose logic.

Screenshot 2024-04-10 at 16 34 11

iankduffy avatar Apr 10 '24 15:04 iankduffy