Firefox scrolling sometimes linked to previous scroll position

I have a website where there is a link at the footer to a particular page state, e.g. the Rules. I say page state since the site is a single HTML page and individual “pages” are simply states of that one HTML page with certain content displayed and other content hidden. The footer content is the same and visible on all page states.

Regardless of what page state one is on, the link from the footer ought to navigate one to the top of the Rules page. And it does this except when the footer link is clicked from one particular page, in which case it goes to the end of the Rules page.

This anomaly is not experienced in either Chrome or Edge, in either desktop or mobile versions of such browsers.

The code script associated with the link to the Rules page is:

/** Moves browser to the Governance page and scrolls to the top of the page
*/
const switchToRulesPage = () => 
{
    if ('scrollRestoration' in history)         
    {
        history.scrollRestoration = 'manual';                                                                           
    }   

    window.scrollTo(0,0);                                                                                               

    switchPage('about-link', 'governance-cont', false);                                                                                     
}

I have tried re-ordering the above code so that the page state switch is done first and then the scroll to the top. But there is no change in browser behaviour.

For what it’s worth, I’ve removed all errors from the HTML page via W3C Validator.