The problem I am having is getting back to the same position in the list page.
Currently I have a session which saves the ID of the record that was clicked.
So when you hit the back button, it should when the database has loaded, smooth scroll to the recordID, but it is just not working.
I’ve also added the ID into the url, this only works when you refresh the page.
Can anyone spot where I am going wrong or if there is another way of doing this?
That is because the scroll event runs before your products are loaded and rendered on the page, so the element it tries to scroll to is not on the page yet.
I think you should first work on optimizing this page, before actually worrying going back to a specific record. Your page is loading hundreds of records and hundreds of images at once.
Your page takes 55+ seconds to fully load and it loads 60 MB of data on load! That is a huge issue.
then, you want to run the scroll code after the repeat region has rendered, so that you are sure the products are on the page. So remove this from your server action