Unsaved changes warning can be misleading

The new “Warn users if page has unsaved changes” feature has been extremely helpful.  Unfortunately, we are running in to an issue with pages that have “helper” models that will never be saved.  In this case, if the user doesn’t change anything on the page, they still encounter the warning because there is a model (manipulated programmatically client side) that triggers the warning.

Would it be possible to add a “track” changes option to each model that would be incorporated in the “unsaved changes” check on beforeunload?  Or some other similar concept or is there a workaround that could be used?

I have granted login access.  Sample page is SampleUnsavedChangesWarningRepro

Steps to reproduce:
1) Create a tab page on Account
2) Add a JS Inline resource with the following code: 
** Note that the same behavior exists if the model is defined in page builder and then manipulated (e.g. createRow/updateRow) in code

(function(skuid){&nbsp; &nbsp; <br>// The below is for demonstration purposes only<br>// and is not to be considered production consumable code<br>// Only intended to demonstrate unsaved warning will be triggered<br>var $ = skuid.$;<br>var clientSideModel = new skuid.model.Model();<br>clientSideModel.id = 'clientSideModel';<br>clientSideModel.recordsLimit = 1;<br>clientSideModel.fields = [<br>&nbsp; &nbsp; &nbsp; &nbsp; { id: 'Color__c' }<br>];<br>clientSideModel.initialize().register();<br>var row = clientSideModel.createRow();<br>clientSideModel.updateRow(row, 'Color__c', 'blue');<br>})(skuid);
  1. Preview the page
    4) Navigate away by choosing any link available making sure to say on the current window

    Actual Result:
    Unsaved changes will be lost warning is encountered

    Desired/Expected Behavior
    No warning is encountered

    Thank you!

Barry - we have seen this problem in our work. There are places where helper models really should be ignored by the Unsaved Changes warning.  

We’d reccomend either turning the unsaved changes off in those pages,  or writing your own Warning tied to the onUnload event - and looking at the “has changes” property of the modelds you care about. 

We are concerned about model property bloat and have not yet decided whether we should tune the saved changes warning so precisely. 

Thanks for sending us the details though… 

Thanks Rob.  The custom beforeonload was my backup plan so I’ll go with that.

Regarding model property bloat, completely understand.  One other option that I can think of is adding a page property for “Models to Track.”  It could be conditionally available in the builder if “warn unsaved changes” is enabled or could just be merged in to a single property as a multi-picklist similar to “save/cancel models” ui in the builder.  This would avoid adding more properties to models but still provide for the declarative approach to eliminating helper models from unsaved changes.


Hey Rob.  Realized that my suggestion above regarding a new page property wouldn’t account for programmatically created models since in order to pick it from a multipick list the model would have to be declaratively defined on the page.  In that case of models created in code, possibly a new api to registerModelToTrack or a parameter on model constructor or model register.

Just thinking out loud, thanks for listening :slight_smile:

No worries Barry. Thanks for offering up the suggestions.  We really appreciate your willingness to help us push the product further…

Perhaps, in addition to the page setting, a model setting can be made that the unsaved error warning will not show for changes made on that model.

I find that I occasionally use a model for UI rendering purposes which triggers the warning unnecessarily but I don’t want to shut the warning off on that page either.