Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

React select check on key down event whether menu is open or closed

I am using react-select in my project for the select elements.

I wonder if there is a way to check on keydown event in the select (can be both the select input or on the menu) if the menu is open or closed.

I am using react select version ^2.4.2, and have to support explorer.

P.S: for whoever is not familiar with the react-select library: it doesnt create typical HTML 'select' and 'option' elements, but rather a text input and on each click (or some dedicated keydown events (accessibility)) on the input/menu - it toggles a div with the options.

Thank you!

like image 317
Adam Mor Avatar asked Sep 07 '25 05:09

Adam Mor


1 Answers

found the answer for it - I am using the built in onMenuClose and onMenuOpen props to toggle a custom attribute (e.g. 'is-open') value between true/false on the input.

like image 86
Adam Mor Avatar answered Sep 09 '25 23:09

Adam Mor