question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

option for manually closing dropdown menu when onBlur

See original GitHub issue

Hi, 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:closed
  • Created 6 years ago
  • Reactions:13
  • Comments:7

github_iconTop GitHub Comments

5reactions
sag1vcommented, Dec 31, 2019

would be nice for an “Always-opened” feature

5reactions
green-arrowcommented, Apr 26, 2017

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.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found