[SalesForce] How to auto close LWC quick action from JavaScript

I have created a Lightning web component quick action for account object in the Summer 2021 sandbox org. This is the screen action and working fine, but I am not able to close the action using JavaScript. I know we can use $A.get("e.force:closeQuickAction").fire(); in the Aura Components, but what is the Lightning web component equivalent for this?

I tried to find the documentations for this but seems to be not available at this time.

Best Answer

Per today's Summer 21 release webinar, you will need to do two things

Add a new import:

import { CloseActionScreenEvent } from 'lightning/actions';

Then add a simple method to close it:

closeQuickAction() {
        this.dispatchEvent(new CloseActionScreenEvent());
    }

You can then call that and it will close the quick action. More details here

H/T to Fabien Taillon for the heads up on this one

Related Topic