Get Notified About Unsaved Changes
Notify the UI about unsaved changes in your component with the lightning:unsavedChanges Aura component. You can use lightning:unsavedChanges in standard and console navigation apps. You can then use a controller to save or discard the changes.
Where: This change applies to orgs with Lightning components in Lightning Experience, Salesforce Classic, and all versions of the Salesforce app.