Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Antd Popover close only when click on a button

Tags:

popover

antd

Here is sandbox Antd pop over

As you can see in the example when you click out side anywhere, popover automatically closed. I want to disable that thing and close it only through click on a button. I don't see such options in Popover and Tooltip apis. Is this possible?

like image 252
I.ali Avatar asked Sep 23 '18 23:09

I.ali


1 Answers

For this you need to remove your onVisibleChange={this.handleVisibleChange} method. You can call this.handleVisibleChange function on button click as given below:

<Popover
    content={<a onClick={this.hide}>Close</a>}
    title="Title"
    trigger="click"
    visible={this.state.visible}
  >
    <Button onClick={this.handleVisibleChange} type="primary">Click me</Button>
</Popover>

I have created a working example on codesandbox.io.

like image 52
Triyugi Narayan Mani Avatar answered Oct 20 '22 19:10

Triyugi Narayan Mani