14

I'm trying to build a Lightning Component Quick Action for Record Quick Action as well as Global Quick Action.

The component opens in a Modal popup in center of screen when in Record View and it opens in a popup along the bottom of the screen when called from Global Action menu (+) symbol in header.

To close the popup I've added following Event Call:

var dismissActionPanel = $A.get("e.force:closeQuickAction");
dismissActionPanel.fire();

This works for Record based Quick Action modal dialog and closes it, but it doesn't do anything when called in Global Quick Action.

Here is my complete code for the Lightning Component:

testGlobalCmp.cmp

<aura:component implements="flexipage:availableForRecordHome,force:hasRecordId,force:lightningQuickActionWithoutHeader" access="global" >
    <div class="slds-p-around--medium">
        <h2 class="slds-text-heading--medium" >Test Heading</h2>
    </div>
    <div class="slds-p-around--medium">
        Test content of module
    </div>
    <div class="slds-p-around--medium">
        <ui:button label="Cancel" 
                   class="slds-button slds-button--neutral cuf-publisherCancelButton uiButton"
                   press="{!c.cancelBtn}"/>
        <ui:button label="Save &amp; Close" 
                   class="slds-button slds-button--brand cuf-publisherShareButton uiButton"
                   press="{!c.saveAndCloseBtn}"/>
    </div>
</aura:component>

testGlobalCmpController.js

({
    cancelBtn : function(component, event, helper) {
        // Close the action panel
        var dismissActionPanel = $A.get("e.force:closeQuickAction");
        dismissActionPanel.fire();
    },
    saveAndCloseBtn : function(component, event, helper) {
        // Display the total in a "toast" status message
        var resultsToast = $A.get("e.force:showToast");
        resultsToast.setParams({
            "title": "Save Success!",
            "message": "A test save success toast!"
        });
        resultsToast.fire();
        // Close the action panel
        var dismissActionPanel = $A.get("e.force:closeQuickAction");
        dismissActionPanel.fire();
    }
})

And then I created a Quick Action in a object say Contactand also created a Global Quick Action and updated Publisher Layout to add the newly created quick actions to it.

2 Answers 2

9

Use $A.get("e.force:closeQuickAction").fire();inside your component controller at the necessary place. This line will close the modal box automatically.

3
  • You havn't noticed my question, that I had already used this line and the component was not closing despite getting this event executed.
    – VarunC
    Commented Jul 12, 2017 at 12:47
  • can u try once by removing the "dismissActionPanel" variable. Use this line instead $A.get("e.force:closeQuickAction").fire(); , this line works well for me.
    – Aruna
    Commented Jul 13, 2017 at 5:23
  • just an FYI, I did found a Known issue for this issue and it has been fixed. I'm gonna put it into an answer since the code I used was fine and is working good now.
    – VarunC
    Commented Jul 13, 2017 at 9:01
5

The code I used was fine. I found following Known Issue existing for this same issue and it has been Fixed already in the platform now, and the Close behavior is not consistent with this Event firing from any context.

https://success.salesforce.com/issues_view?id=a1p3A0000001CcxQAE&title=lightning-component-which-uses-force-closequickaction-is-working-when-added-as-object-action-but-not-as-global-action

You must log in to answer this question.

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