Notify user about unsaved changes – Lightning Component

A user has just filled 20+ input boxes in your Lightning component and accidentally refreshed the page (that command+R can be tricky),  feel the frustration of the user in this case. Well lightning:unsavedChanges is here for our rescue.

In Spring19, Salesforce has introduced new Lightning component “lightning:unsavedChanges” which can help us notify the user about unsaved changes in case of page refresh or page close.

Check out below example:

  • In this example, the user will have 2 input boxes, if the user inserts any value in these input boxes and reload the page, the browser will show an alert box to confirm the change.
  • If the user clicks on the save button, then the browser will not show any alert.

Component File

Controller File

Helper File


(Visited 539 Times)

Leave a Reply

Your email address will not be published. Required fields are marked *