React Bootstrap - How to manually close OverlayTrigger

Todd Chambery picture Todd Chambery · Jul 19, 2016 · Viewed 15.9k times · Source

I have an OverlayTrigger wrapping a Popover that contains some form inputs and a Button to save the data and close.

save(e) {
  this.setState({ editing: false })
  this.props.handleUpdate(e);
}

render() {
    return (
      <OverlayTrigger trigger="click"
        rootClose={true}
        onExit={this.save.bind(this) }
        show={this.state.editing}
        overlay={
            <Popover title="Time Entry">
              <FormGroup>
                    <ControlLabel>Data: </ControlLabel>
                    <FormControl type={'number'}/>
              </FormGroup>
              <Button onClick={this.save.bind(this) }>Save</Button>
           </Popover>
        }>

I have rootClose = true, and my callback gets executed onExit, but I don't see a way to manually close overlay. I'm trying to use the show attribute from the Bootstrap Modal that (predictably) doesn't work.

Answer

Noah John Ucab picture Noah John Ucab · Dec 4, 2017

Hide function is not a public function on OverlayTrigger. Set <OverlayTrigger rootClose={true}... and then on your onClick event trigger call document.body.click().