How to Add a Leave Confirmation on Close Icon Click in Shopify App Bridge Modal?

How to Add a Leave Confirmation on Close Icon Click in Shopify App Bridge Modal?

johndoe315
Shopify Partner
2 0 1

"I want to customize the behavior of the close icon in a Shopify App Bridge modal. Specifically, I want to add a confirmation prompt when the user tries to close the modal, asking if they're sure they want to leave the page. If they confirm, the modal should close; if not, the modal should remain open.

The issue I'm facing is that when both the App Bridge modal and the save bar are open at the same time, clicking the close icon on the modal automatically closes it, even though I want to prevent that behavior if the save bar is still active. How can I ensure that the modal only closes after the confirmation prompt is triggered, and it doesn't close automatically when the save bar is open?"

Replies 0 (0)