113

I'm using react-select and I'm customizing it,I didn't found an option to do this. Is there some workaround I can use to keep dropdown open when I'm styling it?

2

12 Answers 12

202

In chrome, got to Elements > Event Listeners > open "blur" > with the mouse go to the right of where it is written "document", then you can see a button "Remove" > click on it

Sign up to request clarification or add additional context in comments.

2 Comments

perfect answer, this covers all cases
with the latest versions you may need to delete the "focusout" event listener instead of blur.
75

If you're using V2 there's a menuIsOpen prop you can use to keep the menu open at all times.

If you're using Chrome and you have the React Developer Tools plugin, you can inspect your component in the React tab of the console and manually toggle this property right from your browser. For V1, you can toggle the isOpen state to achieve the same behavior.

1 Comment

I use menuIsOpen. it worked but when I click on select for change my selected option, It didn't open again.
58

That's work for me:

menuIsOpen={true}

2 Comments

Worked Fine, this should be the right answer
This is the right answer, but is crypted.... Set the property menuIsOpen to true, by code or if you have the React Developers Tool browser extension , you can set it temporally with this tool
21

Simple hack goes this way

Run this command on your console open the menu and then wait for 5 seconds and the debugger will automatically be applied and screen will be freezed.

setTimeout(() => {debugger;}, 5000)

3 Comments

If using F8 does not work this is second easiest solution. Thanks!
Used to do this; note however that this may prevent e.g. React Dev Tools from working - removing the blur handler per the top answer works better!
Nice one, works for me where the other solutions failed. 👍
9

Beforehand I exec window.onkeydown = () => {debugger} in js console and after expanding the dropdown I click any key

It's important to keep developer tools open

1 Comment

Doesn't work on Windows 10 Chrome 80+. Dropdown is closed as soon as debugging starts.
9

2023 answer for Google Chrome: You can enable "Emulate a focused page" by using Cmd/Ctrl + Shift + P in Chrome devtools and that won't blur the document if you use devtools. Very handy for debugging focus styles, focus handler, dialogs, popovers, dropdowns, etc. enter image description here

1 Comment

worked for me with shad-cn Select component
6

in select component send this as props

menuIsOpen={true}

Comments

4

You can use the menuIsOpen props. It was on the react-select documentation and it works! Docs: https://react-select.com/props Screenshot: enter image description here

Comments

3

Maybe this could help:

<Select 
   ref={el => (this.selectRef =el)}
   onBlur={() => {
     setTimeout(
       () => 
          this.selectRef.setState({
            menuIsOpen: true,
          }),
        50
     );
   }}
  />

1 Comment

this is the only thing that worked. by the way, you cannot use this inside set timeout that way, you have to create a variable reference outside
2

By using the Chrome React extension, you can force the "isOpen" (v3: "menuIsOpen") state value to true on the Select component.

more info here: https://github.com/JedWatson/react-select/issues/927#issuecomment-313022873

Comments

1

If you are using Google Chrome to debug. You can hover over the select drop down and press Ctrl+Shift+C simultaneously and it should be automatically selected in the debug window

Comments

-6

Open dropdown and then right click on dropdown... it will drown a pop over and on inspector.. now you can work upon your dropdown.

2 Comments

As soon as you click somewhere in the inspector you will lose the focus.
This actually won't work, the problem is you cannot perform any action or the menu would disappear

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.