govuk-browser-extension
govuk-browser-extension copied to clipboard
Extension doesn't preserve browser history
When using the extension links such as Production, Staging and Integration, the URL changes as expected.
However, pressing the Back button does not take you back to the previous page.
We should look into using the History API to push the change to the history array, to fix the back button behaviour.
I see this was reported a while ago but it's still the case and it's still very annoying when trying to debug something.
Investigating this with the following journey:
- Navigate to GOV.UK homepage
- Click on Benefits
- Open the extension, click on Content Item
- Press the back button
On Chrome, the page that you end up on is the GOV.UK homepage and not Benefits (which is what would be expected). In Firefox this issue does not occur, it will go back to Benefits. When running this with Developer Mode turned on in Chrome extensions, I see the following console output:
Navigation to https://www.gov.uk/ was restored from back/forward cache (see https://web.dev/bfcache/)
The history (when right clicking the background) appears to be correct. Benefits appears in the dropdown and can be navigated to. When pressing back however, we get on the homepage.