When used as actions, components that implement the force:lightningQuickAction interface display in a panel with standard action controls, such as a Cancel button. These components can also display and implement their own controls, but should be prepared for events from the standard controls.
Components that implement the force:lightningQuickActionWithoutHeader interface display in a panel without additional controls and are expected to provide a complete user interface for the action.
These interfaces are mutually exclusive. That is, components can implement either the force:lightningQuickAction interface or the force:lightningQuickActionWithoutHeader interface, but not both. This should make sense; a component can’t both present standard user interface elements and not present standard user interface elements.
<!--quickAdd.cmp--> <aura:component implements="force:lightningQuickAction"> <!-- Very simple addition --> <lightning:input type="number" name="myNumber" aura:id="num1" label="Number 1"/> + <lightning:input type="number" name="myNumber" aura:id="num2" label="Number 2"/> <br/> <lightning:button label="Add" onclick="{!c.clickAdd}"/> </aura:component>
/*quickAddController.js*/ ({ clickAdd: function(component, event, helper) { // Get the values from the form var n1 = component.find("num1").get("v.value"); var n2 = component.find("num2").get("v.value"); // Display the total in a "toast" status message var resultsToast = $A.get("e.force:showToast"); resultsToast.setParams({ "title": "Quick Add: " + n1 + " + " + n2, "message": "The total is: " + (n1 + n2) + "." }); resultsToast.fire(); // Close the action panel var dismissActionPanel = $A.get("e.force:closeQuickAction"); dismissActionPanel.fire(); } })
The results of the add calculation are displayed in a “toast,” which is a status message that appears at the top of the page. The toast is created by firing the force:showToast event. A toast isn’t the only way you could display the results, nor are actions the only use for toasts. It’s just a handy way to show a message at the top of the screen in Lightning Experience or Salesforce1.
What’s interesting about using a toast here, though, is what happens afterward. The clickAdd controller action fires the force:closeQuickAction event, which dismisses the action panel. But, even though the action panel is closed, the toast still displays. The force:closeQuickAction event is handled by the action panel, which closes. The force:showToast event is handled by the one.app container, so it doesn’t need the panel to work.