0

I believe this is an issue that is related to the bfcache (back-forward cache) in Chrome 79 as this wasn't an issue in Chrome 78. The code below demonstrates the issue when using the latest version of Chrome on Windows 10.

<html>
    <head>
        <title>Test Page</title>
    </head>
    <body>
        <h1>Test Page</h1>

        <select id="example" multiple>
            <option>Black</option>
            <option>Cyan</option>
            <option>Magenta</option>
            <option>Yellow</option>
        </select>

        <a href="https://www.google.com/">Google</a>

        <script type="text/javascript">
            window.onpageshow = function () {
                //setTimeout(function () {
                    console.log(document.querySelectorAll('#example option:checked').length);
                //}, 100);
            };
        </script>
    </body>
</html>

Select items in the dropdown and then navigate away from the page using the hyperlink and when returning to the page by pressing the browser back button the previously selected items aren't reflected in the pageshow event but are on the webpage.

The only way I was able to workaround this was to set a short timeout (see commented out code). Anyway I'm hoping someone reading this is able to reproduce in Chrome 79 and if so, suggest the best way to resolve the issue.

Mark G
  • 2,848
  • 1
  • 24
  • 32
  • I tried filing this as a bug at https://bugs.chromium.org/p/chromium/issues/list but each time I got a 400 Bad Request ¯\\_(ツ)_/¯ – Mark G Dec 18 '19 at 00:01

1 Answers1

0

This was a regression caused by Restore form control state on finishing document parsing now fixed in Chrome 80. See Issue 1035662: Chrome 79 not reflecting DOM state in onpageshow after back navigation.

Mark G
  • 2,848
  • 1
  • 24
  • 32