I have two different lighting components that launch an overlay with the same component inside it. The overlay provides the user a modal to select some options and upload a file using lightning:fileUpload.
The modal then fires an <aura:event type="APPLICATION"> when the upload is complete. This is an APPLICATION event that I am using to automatically close the modal (from the "parent" component) once the user acknowledges that the file upload is complete. For additional details on how that works see this answer.
So I have two components that contain

<aura:handler event="c:fileUploaded" action="{!c.handleFileUploaded}"/>
<lightning:overlayLibrary aura:id="overlayLib"/>

But only one component seems to be able to catch that event. I put a breakpoint in the handleFileUpload of each component to see which is getting called. It was always Component1. When I removed the aura:handler line from Component1 then Component2 was able to catch the event. But never both.
I understand from the docs that APPLICATION events can be caught and handled by anybody and everybody. So why isn't this working for me?

1 Answer 1


Sometimes it's the simple things. There was an error in my code.
The problem was that both parent components assumed that

<aura:attribute name="modalPromise" type="Aura.Action"/>

has a value, when in fact only the component actually launching the modal had a value.
So what happened was the first component to catch the event would just call

component.get('v.modalPromise').then(function (modal){

and that of course would fail because component.get('v.modalPromise') returns undefined. So the JS would quietly die and I would have no clue.
Adding a simple if (component.get('v.modalPromise')) in both parent components solved the issue, and now both components handle the event.
It turns out there Aura was sort of letting me know that there was an error. Buried deep in the page markup was

<div id="auraErrorMessage">This page has an error. You might just need to refresh it.
    [NoErrorObjectAvailable] Script error.

But go try and solve the problem based on that wealth of helpful information.

You must log in to answer this question.

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