You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The "unsaved warning" button and "are you sure you want to leave?" confirmation dialogue should only appear when something has actually been changed. However, in some cases, it shows up before any changes have been made.
Steps to reproduce:
Start on the sample table page
Load a sample or cell
Press the browser "back" button
Load the same sample/cell again.
-> "Unsaved changes" warning appears.
Try to leave this page
-> "are you sure you want to leave?" dialogue comes up.
Normally, the "unsaved changes" warning is automatically set by the computed setters for each field, as defined in field_utils.js. However, this only works for primitive types. The constituent tables use Arrays/Objects, and the computed setters don't properly work for these as they can't detect deep changes (at least as far as I've been able to figure out).
So, we use a deep watcher on constituents to detect any deep changes and set the unsaved warning. In most cases this works fine, but in the above case, a bug arises. The original data is still in the store, and getSampleData() is called again.
The constituents array gets regenerated and gets a new js reference, even though the actual data stays the same. Therefore, the watcher triggers even though the data didn't really change.
#606 gives a fix that will hopefully fix this by removing the warning right after a page load, but I want to put some other possible solutions here in case this comes up in the future.
In the watcher, explicitely do a deep check that the oldConstituents and newConstituents are actually different in content, not just reference. Downside to this is that the code is a little tricky to write, and it could potentially be slow if the constituent table was ever very large (though if that is the case, the deep watch is probably already slow).
Clear an item's data from the store whenever the page is unloaded.
The "unsaved warning" button and "are you sure you want to leave?" confirmation dialogue should only appear when something has actually been changed. However, in some cases, it shows up before any changes have been made.
Steps to reproduce:
-> "Unsaved changes" warning appears.
-> "are you sure you want to leave?" dialogue comes up.
Previous work on this behavior: #223 #257
The text was updated successfully, but these errors were encountered: