I'm using lightning:openFile event to allow users to upload new versions of a ContentDocument. I know Salesforce recommends not to do that. But tough.
Anyway, I need to capture the event fired when the modal is closed. After the user uploads a new version, I need to send an event to the parent component (the one that fired the lightning:openFile event) to refresh the thumbnail it is displaying.
So, does anybody know which event that is?

2 Answers 2


How are the files being uploaded? Are you using the lightning:fileUpload standard component (https://developer.salesforce.com/docs/component-library/bundle/lightning:fileUpload/documentation)? If you're instantiating this component by code, you can pass in an onuploadfinished argument (a function). In my experience, this function executes when the modal is closed (that is, the confirmation modal resulting from the file upload). According to Salesforce's documentation, this function runs "when the files have finished uploading", but I've found that it runs when the modal is closed (at least currently).

Something like:

      "label": "Test file upload",
      "onuploadfinished": function(){
         // *** Run logic for modal closed event here *** 
   function(newComponent, status){
      // Callback from component creation
  • No, I'm using the Lightning openfiles event. Clicking a thumbnail fires the event. Pretty sure it launches a Chatter thing. It launches the file overlay with options in the header (download, delete, upload new version, etc'). The same thing you get if you click a file from the record page (in LX). Commented Jan 17, 2019 at 9:39

After a solid month of back and forth with Salesforce support we have reached the conclusion that there is no sanctioned way to do this.
Not content with their answer, I dove into the JS code for Salesforce's lightning components.
The lightning:openFiles launches a modal that exists outside of the regular page hierarchy. When you click outside the file or click the 'X' to close the modal, it does fire an event, but that event is a COMPONENT type event. And the JS function that handles it also calls event.stopPropagation() on it, so there is no way to catch that.
The lightning:fileUpload component contained within the modal (that is called when you Upload new version) also fires a COMPONENT type event that is caught and handled by the modal (because that is the component that fired it, and sent it a callback function), and then event.stopPropagation().

So, bottom line: this is not a thing that can be done within the Salesforce standard components.
It is relatively trivial to role your own modal with lightning:fileUpload and your very own callback function. The downside is that I still haven't found a way to upload a new ContentVersion to an already existing ContentDocument. So my users are contastly uploading new ContentDocuments (and my controller is deleting the old ones to keep the clutter down. It's a mess.)

You must log in to answer this question.

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