option for manually closing dropdown menu when onBlur
See original GitHub issueHi, thanks so much for this awesome component!
Is it possible to have a function to allow user manually closing the dropdown instead of closing it automatically when blurring? Because what I would like to do is to fire an action before the dropdown closes.
something like additional prop :
onBlurCloseMenu={false}
Then we can do:
onBlur={() => {
setTimeout(() => {
this.setState({
dropdownVisible: false
});
}, 1000);
}}
Issue Analytics
- State:
- Created 6 years ago
- Reactions:13
- Comments:7
Top Results From Across the Web
click anywhere to close dropdown in react - Stack Overflow
My suggestion is that you use the synthetic events onFocus and onBlur to trigger open/close state. onFocus will trigger when the element is ......
Read more >How to avoid dropdown menu to close menu items on clicking ...
How to avoid dropdown menu to close menu items on clicking inside ? · Click Inside: · Click Outside: O/P after click outside....
Read more >How to Close SLDS Dropdown Menu when clicked outside in ...
This should do. You can call this toggleVisibility function from blur of the button as well to close the dropdown. Have this on...
Read more >Dismissing a React Dropdown Menu by Clicking Outside its ...
The onBlur callback is called only after the dropdown menu gets the focus. If the action of clicking outside the component occurs before...
Read more >Select - Ant Design
Select component to select value from options. When To Use. A dropdown menu for displaying choices - an elegant alternative to the native...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
would be nice for an “Always-opened” feature
Bumping this. Being able to manually control when the dropdown menu closes would definitely be useful for many things, such as custom animations. Right now, animating on open is easy with the
onOpen
event, but animating out is not possible.Fwiw, my specific use case is showing the dropdown menu fixed to the bottom of the screen on mobile devices with a semi-transparent overlay on the rest of the page. Animating in is not an issue, but animating out with a slide down would need something like @bryan-foong suggests.
If you’re interested in having this functionality, I can take a look at the code and see if I can get a PR going.