0

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?

1 Answer 1

1

You can't detect nor prevent the standard quick action modal's close button from being utilized. Instead, you'll want to consider using a lightning-modal, and then Enable the Component as a Screen Action as described in lightning-quick-action-panel. You can then use the disable-close property to prevent closing the modal under normal circumstances. However, this is an on/off feature, meaning the user will have to click cancel to close the modal. You can turn the attribute on/off based on if any selections have been made.

2
  • This does not seem to work. Marking this.disableClose to true, does not prevent screen action modal to close. Below is sample code : handleOkay() { this.disableClose = true; } handleClose() { this.disableClose = false; } <targets> <target>lightning__RecordAction</target> </targets> <targetConfigs> <targetConfig targets="lightning__RecordAction"> <actionType>ScreenAction</actionType> </targetConfig> </targetConfigs> Commented Jul 28 at 7:44
  • Also adding this.close() gives below message, but the modal does not close. The LightningOverlay extended component is closed or in the process of closing. this.close() was previously called. Commented Jul 28 at 7:51

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .