3

I want to show a popup message on closing a lightning component to prevent data loss and as a user warning in service console app. For this I have implemented the below:

cmp:

<aura:component implements="flexipage:availableForAllPageTypes" access="global" >
    <force:workspaceAPIAccess aura:id="workspace" />    
    <aura:handler event="force:tabClosed" action="{! c.onTabClosed }"/> 

</aura:component>

JS:

onTabClosed : function(component, event, helper) {
        // you can get use: event.getParams() to get Event parameters
        // eg. var tabid = event.getParam('tabId');

        confirm("Do you really want to close this tab?");
    }

But though it shows the warning popup but closes the window regardless of clicking ok/Cancel on the popup.

to stop this I have already tried as desperate measure:

event.stopPropagation();
event.cancelBubble = true;
Event.stopImmediatePropagation();

Can you please help me with this ? How to stop the component from closing ??

Thanks in advance.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.