Back button fires JavaScript onchange event

Steel Contributor

Currently on Version 81.0.387.0 (Official build) canary (64-bit). Starting a few days (approx. 1/7/20), a problem has developed with our Intranet site so that when we go back, forms are losing (and sometimes actually changing) values. Cannot consistently reproduce, but happens 5-10 times a day. Usually, a refresh (F5) will restore the values, but not always.

 

Ok, now I know what is happening and yet, I have no idea why. When I click Back in Edge, and only Edge (I tested in Chrome and IE), the onchange event of a specific element fires. I can reproduce this consistently.

 

clipboard_image_1.png 

 

 

 

 

 

9 Replies
Isn't "back" button only supposed to take user back to the previous URL?
the contents of the URL can differ, the page might even need to be refreshed to work correctly

@HotCakeX  Never has been a problem before. These are values saved in a database and loaded on each page load. I can't even swear it's the back button, I just know that on subsequent loads of the page, the browser appears to be changing the values of these forms. FYI, I'm the developer for this site, so I can see that the values are being loaded correctly in PHP, this is a UI only issue. 

@HotCakeX 

 

The issue was not "losing values", but somehow JavaScript events are firing that should have no possible way for that to occur.

So no more a UI issue?

@HotCakeX 

 

Well, that was causing the UI issue - the JS being "cached" is an AJAX request that updates part of the page (and not doing it correctly since it should not be fired at that point). I could fix the AJAX issue to work anyway, but I need to know why it's even being called - makes no sense, but I can reproduce 100% of the time in Edge, but not in any other browser.

 

In fact, I just tested all the channels (latest version) - the issue does not occur in Beta or Stable but does occur in Dev and Canary. If this problem makes it to Beta, we will have big problems (we have users on Beta and Stable).

@HotCakeX 

 

I added some debug code so that I could see all AJAX calls made and when I hit the back button, all of these are made that are on the page. All of which are tied to onchange or onclick events of specific elements.

@Keith Davis 

Spoiler

@Keith Davis wrote:

@HotCakeX 

 

Well, that was causing the UI issue - the JS being "cached" is an AJAX request that updates part of the page (and not doing it correctly since it should not be fired at that point). I could fix the AJAX issue to work anyway, but I need to know why it's even being called - makes no sense, but I can reproduce 100% of the time in Edge, but not in any other browser.

 

In fact, I just tested all the channels (latest version) - the issue does not occur in Beta or Stable but does occur in Dev and Canary. If this problem makes it to Beta, we will have big problems (we have users on Beta and Stable).


you can have the fix ready beforehand so in case that happens you will be able to push it and prevent any issue in your organization

 

@HotCakeX 

 

I don't know what you mean. There is no fix AFAIK. If a user hits the back button, JS events fire that should not unless the element is interacted with and I don't know of any way to work around the problem. This could be devastating, even cause data loss for us.

Issue is resolved in:

 

Version 81.0.396.0 (Official build) canary (64-bit)

 

(maybe before, but definitely in this build)