Is there any way to listen to widget close button event?

Im trying to set my react state to false whenever a user clicks on the close button , is there any way to listen to the close button events?

Hi Rohil,

Welcome to the Freshworks Developer Community :bouquet:

I believe you have already explored the widget API document and the usage example. If not kindly refer widget API - Close widget.

You may add a button action to close the widget and change react state from there as depicted below

function closeWidget() {
// write logic to change react state from here

Kindly revert back on how it goes.


Hi Thakur. I’m aware of this function, But my react state does not change if I click on the close icon on the widget itself. I’m currently using the FreshworksWidget('open'); & FreshworksWidget('close'); function on our button to open and close the widget

I have a react state called: isWidgetVisible which I toggle to open and close the widget

I have a button where If I open the widget using FreshworksWidget('open');. I change the state isWidgetVisble:true and if I close isWidgetVisble: false. But if I click the close icon in the widget itself the state is still true because isWidgetVisble:true.

So I thought there would be something I can use to listen to that click event on the button so I can change my react state to false. I couldn’t find any solutions

Hi Rohil,

Thanks for providing additional context. Additionally are you saving react states in redux store? Could you please validate if the react state getting updated correctly?


Hi Thakur. We are using redux in our application but for this, I’m using a local state. And yes the states are working properly

Just to simplify things: When I click on the close icon ( in the widget iframe ). I want to set my state isWidgetVisible to false. Would be great if there is any way to accomplish this

@Asif - Any thoughts here?

@Rohil, were you able to solve this? I need to do the exact same thing (Toggle the isWidgetOpen to false when the widget’s close button is clicked.)

Thank you!

1 Like

@Asif - Awaiting your inputs.

Not really. We just decided to move on, and just disabled the toggle functionality. For now we just use the open functionality and users can close the widget using the close icon.

This topic was automatically closed 6 days after the last reply. New replies are no longer allowed.