Unsaved Changes
lightning:unsavedChanges
A component that can be used to notify the UI containment hierarchy of unsaved changes
For Use In
Lightning Experience
This component provides a way to notify the UI containment hierarchy of unsaved changes and to participate in saving or discarding those changes based on the user's decision.
To access the methods, create an instance of the lightning:unsavedChanges component inside of your component and assign an aura
This example demonstrates how to call the setUnsaved changes method when a button is clicked and how to handle the user's decision to save or discard the unsvaed content.
The buttons invoke the makeUnsavedChanges and clearUnsavedChanges client-side controller methods. If the user takes some action that would lose unsaved content such as closing its console tab container then a dialog appears prompting them to save or discard it. The handleSave or handleDiscard method is called based on their selection. These methods are required to call the setUnsavedChanges() method to return control back to the Lightning UI, as demonstrated below.
For more information, see the Console Developer Guide.