Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ReactBootstrap popover dismiss on click outside

ReactBootstrap provides a popover control. I would like this to be dismissed on clicking outside the popover in a similar way to how modals work (it just dismisses by default clicking out of the box).

Is there a way to do this using ReactBootstrap or do I need to custom code something?

JSfiddle of a popover: http://jsfiddle.net/226cwe4e/

React.createClass({
    render: function() {
        return <ReactBootstrap.OverlayTrigger trigger="click" placement="bottom" overlay={<ReactBootstrap.Popover title="Popover bottom"><strong>Holy guacamole!</strong> Check this info.</ReactBootstrap.Popover>}>
        <ReactBootstrap.Button bsStyle="default">Holy guacamole!</ReactBootstrap.Button>
      </ReactBootstrap.OverlayTrigger>;
    }
});
like image 568
Not loved Avatar asked Mar 09 '15 04:03

Not loved


People also ask

How to hide popover on click?

To hide the displayed popover, use the popover(“hide”) method.

How do you use popover in bootstrap react?

We can use the following approach in ReactJS to use the react-bootstrap Popover Component. Popover Props: arrowProps: It is used to position the popover arrow. content: It is used to create a Popover with a Popover.

What is an Overlay React?

React Overlays is a toolkit for creating functional overlays, tooltips, modals, and dropdowns. It is not a UI framework but is meant to be incorporated into frameworks. To make those integrations possible, React Overlays is style-agnostic and does not come with any CSS.

How do I use Bootstrap tooltip in react?

We can use the following approach in ReactJS to use the react-bootstrap Tooltip Component. Tooltip Props: arrowProps: It is used to position the tooltip arrow. id: It is just an HTML id attribute that is necessary for accessibility.


Video Answer


1 Answers

No you don't need any custom code. Just include rootClose prop and this will do for you. Its in the react bootstrap official documentation https://react-bootstrap.netlify.com/components/overlays/#overlays-api

<OverlayTrigger trigger='click' rootClose>
  ....
</OverlayTrigger>
like image 169
makuno Avatar answered Oct 02 '22 05:10

makuno