The documentation shows how to close an overlay immediately after showing the modal, however, this is not very useful for real-life situations.
I have a component which has a lightning:overlayLibrary
in its markup. When a button is clicked, the controller fires a showCustomModal
with a child component as its content. The child component has a button that fires an event when pushed. The parent component handles the event and should close/destroy the modal.
I've tried component.find('overlayLib').notifyClose()
in the event handler, however, it seems that this fires an event that needs to be handled.
How would one go about handling this event or is there an easier way to do this?