We are using an LWC as a quick action.
I believe that since the screen type is ScreenAction, Salesforce is creating a new modal window (inclusive of an X icon), and rendering our component's markup inside it.
The component displays a lighting-datatable of records, and if the user selects some records from that table and happens to click on the Cancel button (this is a custom lightning-button named Cancel in the modal footer), we have to show a lighting-confirm asking weather the user is sure to close the modal as he has unsaved changes. If he answers yes, we programatically close the modal by firing the CloseActionScreenEvent().
The problem is that when the user clicks on the 'X' icon on the top-right of the modal, the modal closes automatically and the lightning-confirm does not show
How can we detect the clicking of the 'X' icon on the top-right?